在 Android 中禁用快速设置磁贴

Disable quick settings tile in Android

我找不到以编程方式禁用 Android 中的 快速设置磁贴 的方法,这是我们企业启动器的要求。

除了How to disable the notification bar pull-down in Android? and https://e2e.ti.com/support/embedded/android/f/509/t/283260

还有什么线索吗

可以吗?谢谢!

您可以全屏模式启动您的应用程序吗? 就像这里解释的那样:

<activity
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  ....
>

好像根本做不到

这就是答案。

不,并非不可能。使用ACTION_CLOSE_SYSTEM_DIALOGS防止锁屏时被下拉

是的,你可以做到。我使用了以下代码片段来禁用快速设置。

public static void preventStatusBarExpansion(Context context) {
        WindowManager manager = ((WindowManager) context.getApplicationContext()
                .getSystemService(Context.WINDOW_SERVICE));



        Activity activity = (Activity)context;
        WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
        localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
        localLayoutParams.gravity = Gravity.TOP;
        localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|

                // this is to enable the notification to recieve touch events
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |

                // Draws over status bar
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

        localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        int resId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
        int result = 0;
        if (resId > 0) {
            result = activity.getResources().getDimensionPixelSize(resId);
        }

        localLayoutParams.height = result;

        localLayoutParams.format = PixelFormat.TRANSPARENT;

        customViewGroup view = new customViewGroup(context);

        manager.addView(view, localLayoutParams);
    }

在任何需要的地方调用这个方法。在调用此方法之前,请确保您具有屏幕覆盖权限。 但是,Oreo 已弃用此权限。