我可以在我的 android 应用程序中禁用 systemui 吗?

Can I disable systemui From within my android app?

我使用这个答案为我的应用实现了 Kiosk 模式:

我使用 Kingo Root 对平板电脑进行了 root,然后执行了以下命令:

adb shell >
 su >
 pm disable com.android.systemui >

我正在开发一个应用程序,该应用程序将仅在我们的设备上用作信息亭....

它工作得很好但是..我想从 Android 应用程序本身执行系统 ​​ui 的禁用和启用。

是否可以从应用程序中发出系统命令?

/**
 * Uses Root access to enable and disable SystemUI.
 * @param enabled Decide whether to enable or disable.
 */
public void setSystemUIEnabled(boolean enabled){
    try {
        Process p = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(p.getOutputStream());
        os.writeBytes("pm " + (enabled ? "enable" : "disable") 
                + " com.android.systemui\n");
        os.writeBytes("exit\n");
        os.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

工作正常。用法:

setSystemUIEnabled(true);  // Enable SystemUI
setSystemUIEnabled(false); // Disable SystemUI