How to programmatically remove/hide the system bar in Honeycomb (requires root)

 原文地址 http://android.serverbox.ch/?p=306

 

 

 

Without the system bar it is almost impossible to control your Honeycomb tablet. Since no hardware control buttons are enforced for the tablet the system bar is the only way to control your slate.

However, if your application incorporates a way of removing the bar and on leaving restarting the bar there is no reason why not to support such a feature.

The easy part: Restarting the bar

Restarting the bar is pretty simple, drop to a shell and start the service using the “am” command:
# am startservice -n com.android.systemui/.SystemUIService

The difficult part is to shut it permanently down. One way is to navigate to the application settings and shut it down with the “force close” button. However, attempting to kill the process with

# killall com.android.systemui

will remove the bar for a few seconds. Sadly, it will return eventually since in the applications manifest file the “persistent” parameter enforces the system to restart the service unless it is shut down properly by the “system” user itself.

The following magic line will shut down the bar permanently if executed as root:

# service call activity 79 s16 com.android.systemui

What it does is sending the Activitymanager a shutdown signal for the systemui service.
This method was tested on an Iconia A500 with Android 3.01; although it should work with other devices as well (since the source code that we use is common).

Putting it together

To remove the system bar from your application create and execute a process:

Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
proc.waitFor();

To restore the system bar use the following code snippet:

Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
proc.waitFor();

 

你可能感兴趣的:(String,service,command,application,System,Signal)