13

I'm working in a launcher for Android ICS but I have a problem with tablets.

I can't hide the status bar. I have try it in Android 2.3.X and it's ok. The problem appears only with Android 4.0.

How can I hide it?

Charles
  • 50,943
  • 13
  • 104
  • 142
NachoMV
  • 135
  • 1
  • 1
  • 5

6 Answers6

11

You can not get 100% true full screen in Android 4.0.

Use the following to dim the notification bar (aka. status bar, system bar)

 getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

And use this to hide it

 getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

And, if I guess right, you are trying to achieve a "kiosk mode". You can get a little help with an app named "surelock". This blocks all the "home" and "back" actions.

It is still not perfect but this may be the best we can achieve with Android ICS.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
BladeLeaf
  • 458
  • 1
  • 4
  • 8
  • 1
    I would really like to know how Surelock is able to hide Home and back button to do it within my app. Can you help? – Pascal Jan 23 '13 at 07:31
  • @Pascal SureLock replaces your default launcher, so when you press the back or home buttons you are taken back to SureLock. They also have an option that looks for un-whitelisted processes and kills them. – Matthew Blackford Mar 20 '13 at 04:06
7

It is possible to hide the statusbar on a rooted android device. The program Hidebar does this by killing the systemui process. The program is open source, so you can read all about it in the source code.

See http://ppareit.github.com/HideBar/.

ppareit
  • 423
  • 5
  • 5
  • Do NOT attempt this on Android 4.0 ICS as SystemUI is responsible for just about everything and will result in erratic behavior. It resets the system wallpaper, removes the bottom software buttons, etc. – Tom Jun 16 '12 at 15:57
  • 1
    the suggestion by @ppareit works +1, but one should make themselves familiar with risks involved – ılǝ Nov 17 '12 at 14:56
  • 1
    Thanks @ile. Newer versions of HideBar have a new and more advanced method to hide the systembar. HideBar also supports an interface using 'Intents', so that other applications can ask to hide the systembar. There are added permissions, so that the user knows what applications are allowed to hide the systembar. If you need this this in your own application, you are best to contact me using the address provided on the site of HideBar. – ppareit Nov 17 '12 at 15:52
5

You cannot get rid of the system bar on tablets. You may be able to get rid of the navigation bar and status bar on phones. Please read the "Controls for system UI visibility" section of the Android 4.0 SDK release notes.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ok... i can´t hide it... but can I block /override the actions of the buttons? – NachoMV Mar 15 '12 at 23:17
  • 3
    Why video player is full screen and hides status bar? – NachoMV Mar 15 '12 at 23:21
  • The video player does not hide the system bar on ICS tablets. – CommonsWare Mar 15 '12 at 23:29
  • is possible to disable some of the buttons of the status bar? (notifications/settings and running apps) – NachoMV Mar 16 '12 at 16:41
  • @NachoMV: No. You can dim them, though. – CommonsWare Mar 16 '12 at 17:27
  • How can we dim the (notifications/settings and running apps) button on status bar of tablet? – Shrikant Ballal Aug 21 '12 at 05:47
  • @Shrikant: Use `STATUS_BAR_HIDDEN` or `SYSTEM_UI_FLAG_LOW_PROFILE` with `setSystemUiVisibility()` on any `View`. – CommonsWare Aug 21 '12 at 10:51
  • I used STATUS_BAR_HIDDEN but I am able to click on the running apps button. Basically, I have implemented (custom)lock screen facility in my app where UI will be visible to user but he cannot click on any view from the UI, so for that I have disabled home and back key as well but if user presses the recent activity button, the app can get minimized which I don't want to happen. KEYCODE_APP_SWITCH is also not working. So can you tell me is it possible to ignore this event? – Shrikant Ballal Aug 21 '12 at 11:35
  • @CommonsWare indeed it is not possible within the given framework, but there are workarounds for rooted devices. This can be very useful for developers looking to create kiosk applications. – ılǝ Nov 17 '12 at 15:02
  • @ılǝ : I am creating a create kiosk mode appln,and need to hide the status bar on my 4.2.2 tablet.Do you know how can I achieve it ? – Basher51 Apr 21 '14 at 05:24
  • @Basher51 You can use the HideBar project but you need super user access to the system, i.e. you need to have rooted the device. See my answer below. – ılǝ Apr 21 '14 at 07:52
4

I know my answer comes a bit late, but after assembling info from various places, I came up with this, which works ONLY ON ROOTED DEVICES:

    private void    KillStatusBar()
{
    Process proc = null;

    String ProcID = "79"; //HONEYCOMB AND OLDER

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
        ProcID = "42"; //ICS AND NEWER
    }

    try {
        proc = Runtime
                .getRuntime()
                .exec(new String[] { "su", "-c",
                        "service call activity "+ProcID+" s16 com.android.systemui" });
    } catch (IOException e) {
        Log.w(TAG,"Failed to kill task bar (1).");
        e.printStackTrace();
    }
    try {
        proc.waitFor();
    } catch (InterruptedException e) {
        Log.w(TAG,"Failed to kill task bar (2).");
        e.printStackTrace();
    }

}

This should eliminate the bottom bar on any rooted device and turn it into "kiosk" mode.

Wildcopper
  • 373
  • 1
  • 3
  • 11
1

To hide status bar and navigation bar in android 4.0, we should use code below:

LinearLayout layout = (LinearLayout)findViewById(R.id.layout);
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
alicanbatur
  • 2,172
  • 1
  • 28
  • 36
1

Building upon ppareit's answer.

You can not hide the navigation bar on most stock devices. However, there is a work around if you rooting the device is an option. Here are the steps for one solution:

  1. Root device

  2. Install and run Busybox (required for taking full advantage of rooted device)

  3. Install HideBar from resource

In HideBar there is an option to run in 'Kiosk' mode, in which there is no way to re-display the navigation bar. Needless to say, you really need to be careful with this.

ılǝ
  • 3,440
  • 2
  • 33
  • 47