Android 禁止下拉菜单栏
生活随笔
收集整理的這篇文章主要介紹了
Android 禁止下拉菜单栏
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Android 禁止下拉菜單欄
如下圖,有時候我們需要禁止用戶下拉出菜單欄。
在解決這個問題之前,我們需要知道,下拉菜單欄總共有兩種,一種是鎖屏下的下拉菜單,一種是非鎖屏下的下拉菜單。因此需要兩種不同的方法,才能將下來菜單欄屏蔽干凈。
1.屏蔽非鎖屏下的下拉菜單欄
這種Android 系統(tǒng)其實是提供了方法的,只不過是隱藏的,只給系統(tǒng)應用,也就是用mk 編譯的apk使用。如果第三方應用想要使用,或者Android stuido 編譯方式的想要使用。則可以使用反射。
/*** Allows an app to control the status bar.*/ @SystemService(Context.STATUS_BAR_SERVICE) public class StatusBarManager {/** @hide */public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND;/** @hide */public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS;/** @hide */public static final int DISABLE_NOTIFICATION_ALERTS= View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS;/** @hide */@Deprecated@UnsupportedAppUsagepublic static final int DISABLE_NOTIFICATION_TICKER= View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER;/** @hide */public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO;/** @hide */public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME;/** @hide */public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT;/** @hide */public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK;/** @hide */public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK;/** @hide */public static final int DISABLE_SEARCH = View.STATUS_BAR_DISABLE_SEARCH;/** @hide */@Deprecatedpublic static final int DISABLE_NAVIGATION =View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT;/** @hide */public static final int DISABLE_NONE = 0x00000000;/** @hide */public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS| DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER| DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK| DISABLE_SEARCH; /*** Disable some features in the status bar. Pass the bitwise-or of the DISABLE_* flags.* To re-enable everything, pass {@link #DISABLE_NONE}.** @hide*/@UnsupportedAppUsagepublic void disable(int what) {try {final int userId = Binder.getCallingUserHandle().getIdentifier();final IStatusBarService svc = getService();if (svc != null) {svc.disableForUser(what, mToken, mContext.getPackageName(), userId);}} catch (RemoteException ex) {throw ex.rethrowFromSystemServer();}}2. 屏蔽鎖屏下的下拉菜單欄
這種沒有接口,只能在systemui 里面修改源碼,來屏蔽掉。
總結
以上是生活随笔為你收集整理的Android 禁止下拉菜单栏的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Swagger体验版
- 下一篇: 翻页时钟java代码_Android编程