我可以在我的Android应用程序中禁用systemui吗?
问题描述:
我使用以下答案为我的应用实现了Kiosk模式: https://stackoverflow.com/a/26013850
I used this answer to achieve a Kiosk Mode for my app: https://stackoverflow.com/a/26013850
我将平板电脑的Kingo Root植根,然后执行以下命令:
I rooted the tablet with Kingo Root and then performed the following commands:
adb shell >
su >
pm disable com.android.systemui >
我正在构建一个仅可在我们的设备上用作信息亭的应用程序.
I am building an app that will only be used on our devices as kiosks....
它的效果很好,但我想从Android应用程序本身执行系统ui的禁用和启用.
It works great BUT.. I would like to perform the disable and enable of the system ui from the Android application itself.
在应用程序中是否可以使用系统命令?
Are system commands possible from within an application?
答
/**
* 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