android 悬浮窗会闪退

ball = LayoutInflater.from(this).inflate(R.layout.xfc, null);
我这么写上去就闪退,不加就没事

参考:

private void permissionFloatingView(){
        if (Build.VERSION.SDK_INT >= 23) {  // Android6.0以上
            if(!Settings.canDrawOverlays(this)) {    // 禁止悬浮
                //手动开启
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                startActivity(intent);
                return;
            } else {    
                // 允许悬浮
                // TODO 显示悬浮窗
            }
        } else {
            // Android6.0以下,不用动态声明权限
            // TODO 显示悬浮窗
        }
    }