在Android中禁用快速设置磁贴

问题描述 投票:0回答:4

我无法找到一种方法来以编程方式禁用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

java android android-launcher
4个回答
1
投票

您可以在全屏模式下启动应用程序吗?像这里解释的那样:https://stackoverflow.com/a/8470893/2801860

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

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中已弃用。


0
投票

似乎根本不可能做到。

这就是答案。


0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.