Can I disable systemui From within my android app?
12,778
/**
* 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();
}
}
Works fine. Usage:
setSystemUIEnabled(true); // Enable SystemUI
setSystemUIEnabled(false); // Disable SystemUI
Related videos on Youtube
Author by
silversunhunter
Updated on June 04, 2022Comments
-
silversunhunter almost 2 years
I used this answer to achieve a Kiosk Mode for my app: https://stackoverflow.com/a/26013850
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....
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?
-
silversunhunter about 9 years@JohnyTex : This is a special case where I needed the users to NOT have the ability to do anything except use my app. The device was owned by my company and put into kiosks. Doing this made it almost impossible to exit whatever app you were in as there was no longer a home button, back button or notification drop down area.
-
-
silversunhunter over 9 yearsI am about to try this but I have one question. Being that I am using a root software made for dummies(one click root access) I am wondering if there is a way for this class to know if it has root access or not.
-
ByteHamster over 9 yearsYou can use this function by calling setSystemUIEnabled(true); somewhere in your code. Just tested it, working fine. Determinung if there is root acces is explained here. Please accept this answer if it helped you.
-
silversunhunter over 9 yearsThis causes a restart of the device (hp 7 slate) Is this a device thing or is this expected on all devices as we are making a fundamental change to the OS?
-
ByteHamster over 9 yearsDid it also restart when you typed in the command manually? It should behave exactly the same way as if you type in the command via adb. While testing, I have just disabled a user app instead of SystemUI so I can not verify the behavior.
-
Amit Hooda over 8 yearshey this is not working for me i have a rooted nexus device and it has root access but the navigation buttons are still visible, when i try from terminal or from application ??? any suggestions ?