我使用以下答案为我的应用程序实现了Kiosk模式:https : //stackoverflow.com/a/26013850
我使用Kingo 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句