Stack Overflow archive
1 scoreaccepted

Programatically disable System Bar (Have Root access)

score
1
question views
470
license
CC BY-SA 3.0

You will need root access to do this from an app because ADB can access /system/bin/service but your app cannot (see GID of app and ADB).

java
Process su = null; 
try { 
    su = Runtime.getRuntime().exec("su");
    String cmd = "service call activity 42 s16 com.android.systemui\n";
    su.getOutputStream().write(cmd.getBytes());
    String exit = "exit\n";
    su.getOutputStream().write(exit.getBytes());
    su.waitFor(); 
} catch (Exception e) {
    e.printStackTrace();
} finally { 
    if (su != null) { 
        su.destroy(); 
    } 
}

You should also check out third party libraries for handling su commands: https://android-arsenal.com/details/1/451

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.