/**
* 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
可以安全地禁用com.android.systemui或在某些设备上发生某些问题吗? – JohnyTex 2015-04-20 14:54:28
@JohnyTex:这是一个特殊情况,我需要用户除了使用我的应用程序之外无法做任何事情。该设备由我的公司拥有,并放入售货亭。这样做几乎不可能退出您所在的任何应用程序,因为不再有主页按钮,后退按钮或通知下拉区域。 – silversunhunter 2015-04-22 19:09:37
我遇到了禁用systemui没有帮助的情况,即使禁用了它也仍然运行。请参阅:http://android.stackexchange.com/questions/119508/app-is-running-even-though-disabled-why 禁用时它如何运行? – JohnyTex 2015-08-17 12:33:56