Is there a way to hide the system bar in Android 3.0? It's an internal device and I'm managing navigation

Solution 1:

Since this is not possible to do using a public API, I have found a way to do it in a very "hack-ish" way that requires a rooted device.

Update: as user864555 pointed below, this is another solution

$ adb remount
$ adb shell mv /system/app/SystemUI.odex /system/app/SystemUI.odexold
$ adb shell mv /system/app/SystemUI.apk /system/app/SystemUI.apkold
$ adb reboot

"That code disable the app SystemUI which is the actually menu bar. Which that modification, you will also gain the space of that system bar. But make sure to have a back button or something to exit."

That works great as well. Please vote for his answer. I will try to keep this one updated as much as I can.


Update: Here's a third method. A way to do it programmatically or using the command line. Found here: http://android.serverbox.ch/?p=306

This method requires root access, but you don't need to change the LCD Density, keeping the same as the original, and you can get the UI nav bar back really quick and easy without having to reboot everytime.

The blog post also shows how to implement it on your Android application, remember it requires root, and it might not be a great idea to do so unless your application is running on a kiosk or your own device, please do not implement this method on an app that's published in the Android market or anywhere public.

To stop/remove/disable the system bar (need to be su before issuing this command):

$ service call activity 79 s16 com.android.systemui

To restore the system bar just simply issue this command:

$ am startservice -n com.android.systemui/.SystemUIService

It's that easy. Hopefully ICS gets released soon along with the source code so that anyone can build Android for our Kiosk tablets.

Solution 2:

You cannot hide the system bar on Android 3.0.

Solution 3:

If you have access to system file, you can do this (mine is unlocked and rooted, so i'm not sure what you need, I haven't tried with a factory fresh xoom):

adb shell
cd /system/app/
mv SystemUI.odex SystemUI.odexold
mv SystemUI.apk SystemUI.apkold
exit
adb reboot

That code disable the app SystemUI which is the actually menu bar. With that modification, you will also gain the space of that system bar, but make sure that you have a back button or something to exit in your app.

Edit:

If you have problems with read-only file, you mint need to mount the /system directory as read-write. To do so, use this command in adb shell (Source: http://forum.xda-developers.com/showthread.php?t=1159495&page=5)

mount -o remount,rw /dev/block/stl6 /system

You can remount it as read-only using that command:

mount -o remount,ro /dev/block/stl6 /system

Edit:

This methods allow the soft keyboard to be displayed normally when needed.

Solution 4:

Here is related code with my previous answer. It automatically hide the status bar and show it back again when finish. Important: to show it back again, the code have to restart system_server which take some time to boot again and during that time, you will see the honeycomb booting animation. That's the only I find for now to show the statusbar again. Restarting SystemUI is not enought. And because of that, it will shutdown your app when restart system_server.

This code need a rooted os with superuser installed on.

package com.projects;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TableLayout.LayoutParams;

// http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/
public class FullScreenTestActivity extends Activity implements Button.OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        try
        {
            Process p;
            p = Runtime.getRuntime().exec("su"); 

            // Attempt to write a file to a root-only
            DataOutputStream os = new DataOutputStream(p.getOutputStream());
            os.writeBytes("mount -o remount,rw /dev/block/stl6 /system\n");
            os.writeBytes("mv /system/app/SystemUI.odex /system/app/SystemUI_Old.odex\n");
            os.writeBytes("mv /system/app/SystemUI.apk /system/app/SystemUI_Old.apk\n");
            os.writeBytes("mount -o remount,ro /dev/block/stl6 /system\n");

            // Close the terminal
            os.writeBytes("exit\n");
            os.flush();
            p.waitFor();

            new AlertDialog.Builder(this)
                .setIconAttribute(android.R.attr.alertDialogIcon)
                .setMessage("Android Honeycomb StatusBar removed successfully!")
                .show();

            // Set action for exiting.
            Button cmdExit = new Button(this);
            cmdExit.setText("Exit");
            cmdExit.setOnClickListener(this);
            this.addContentView(cmdExit, new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        }
        catch (Exception e)
        {
            ShowErrorGlobal(e);
        }
    }

    public void onClick(View v) {
        try
        {
            Process p;
            p = Runtime.getRuntime().exec("su"); 

            // Attempt to write a file to a root-only
            DataOutputStream os = new DataOutputStream(p.getOutputStream());
            os.writeBytes("mount -o remount,rw /dev/block/stl6 /system\n");
            os.writeBytes("mv /system/app/SystemUI_Old.odex /system/app/SystemUI.odex\n");
            os.writeBytes("mv /system/app/SystemUI_Old.apk /system/app/SystemUI.apk\n");
            os.writeBytes("mount -o remount,ro /dev/block/stl6 /system\n");
            String systemServerPID = GetSystemServerPID();
            if (systemServerPID != null)
                os.writeBytes("kill " + systemServerPID + "\n");
            // else ... manual reboot is required if systemServerPID fail.

            // Close the terminal
            os.writeBytes("exit\n");
            os.flush();
            p.waitFor();
        }
        catch (Exception e)
        {
            ShowErrorGlobal(e);
        }
    }

    public String GetSystemServerPID()
    {
        try
        {
            Process p = Runtime.getRuntime().exec("ps -n system_server"); 
            p.waitFor();

            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            reader.readLine(); // Skip header.
            return reader.readLine().substring(10, 16).trim();
        }
        catch (Exception e)
        {
            return null;
        }
    }

    protected void ShowErrorGlobal(Exception e)
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream stream = new PrintStream( baos );
        e.printStackTrace(stream);
        stream.flush();

        new AlertDialog.Builder(this)
            .setIconAttribute(android.R.attr.alertDialogIcon)
            .setTitle("Epic fail")
            .setMessage("Error: " + new String( baos.toByteArray() ))
            .show();
    }
}