Android隱藏禁用虛擬鍵或狀態欄

一. 系統層

mediatek\config\xxxxxxx\system.prop !56

- qemu.hw.mainkeys=0

+ qemu.hw.mainkeys=1

二. 應用層

方法1(隱藏虛擬鍵,觸屏可以拖出來):

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions); 

方法2(禁用虛擬鍵或狀態欄):

public static final int STATUS_BAR_DISABLE_EXPAND = 0x00010000;//禁止下拉通知欄
public static final int STATUS_BAR_DISABLE_NOTIFICATION_ICONS = 0x00020000;
public static final int STATUS_BAR_DISABLE_NOTIFICATION_ALERTS = 0x00040000;
public static final int STATUS_BAR_DISABLE_NOTIFICATION_TICKER = 0x00080000;
public static final int STATUS_BAR_DISABLE_HOME = 0x00200000;
public static final int STATUS_BAR_DISABLE_BACK = 0x00400000;
public static final int STATUS_BAR_DISABLE_RECENT = 0x01000000;
public void setStatusBar(Context context) {
    try {
        Object service = context.getSystemService("statusbar");
        Class<?> statusBarManager = Class.forName("android.app.StatusBarManager");
        Method disable = statusBarManager.getMethod("disable", int.class);
        disable.invoke(service, STATUS_BAR_DISABLE_EXPAND
            		|STATUS_BAR_DISABLE_NOTIFICATION_ICONS
            		|STATUS_BAR_DISABLE_NOTIFICATION_ALERTS
            		|STATUS_BAR_DISABLE_NOTIFICATION_TICKER
            		|STATUS_BAR_DISABLE_HOME
            		|STATUS_BAR_DISABLE_BACK
            		|STATUS_BAR_DISABLE_RECENT);//or 0xffffffff
    } catch (Exception e) {
        e.printStackTrace();
    }
}

注:需要系統權限和簽名

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章