在Android中禁用快速设置磁贴

时间:2018-01-31 05:47:47

标签: java android android-launcher

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

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

之外是否有任何线索

有可能吗?谢谢!

enter image description here

4 个答案:

答案 0 :(得分:1)

您可以在全屏模式下启动应用吗? 如下所述:https://stackoverflow.com/a/8470893/2801860

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

答案 1 :(得分:1)

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

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中不赞成使用此权限。

答案 2 :(得分:0)

似乎根本不可能做。

那是答案。

答案 3 :(得分:0)

不,不是不可能。使用ACTION_CLOSE_SYSTEM_DIALOGS防止在锁定屏幕时将其拉下。