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

sil*_*ter 8 android root kiosk-mode

我使用此答案为我的应用程序实现了Kiosk模式:https://stackoverflow.com/a/26013850

我使用Kingo Root生成平板电脑,然后执行以下命令:

adb shell >
 su >
 pm disable com.android.systemui >
Run Code Online (Sandbox Code Playgroud)

我正在构建一个只会在我们的设备上用作自助服务终端的应用....

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

系统命令是否可以在应用程序中执行?

Byt*_*ter 14

/**
 * 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();
    }
}
Run Code Online (Sandbox Code Playgroud)

工作良好.用法:

setSystemUIEnabled(true);  // Enable SystemUI
setSystemUIEnabled(false); // Disable SystemUI
Run Code Online (Sandbox Code Playgroud)