Question

I need my rooted android tablet to be in a "kiosk-mode", so the notification bar should be disabled (and not just hidden as in for example full-screen games).

This code hides the bar only temporarily:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);    // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                 
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main); 

The same when I put this one in the application section of the AndroidManifest:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

I've tried to disable the android-ui by the adb command

pm disable com.android.systemui

But then I haven't got any navigation buttons! I only need the notification bar on the top to be blocked!

So how can I block notification bar that it cannot be opened?

Was it helpful?

Solution 2

I know, this isn't a general solution to this problem, but in my case I could do it so.
I modded SystemUI.apk.

I removed the background of the statusbar and set height and width to 0dip of the content view.

This can only be done because I serve my app only for my own set of same tablets!!

OTHER TIPS

As far as I am aware there is no official way to do this, as it could be used maliciously, but this is how I have achieved it. It works by rudely killing the system service that handles the Nav/Action bar etc. Crude but its the only thing that I could find that works.

This will block all of the navigation buttons, action bar etc. I'm not aware of a way to only stop one of these

hideNav() is called onCreate in the main activity, and showNav() is called from onDestroy, which you will need if you want a way for an admin to access the OS, as unless you specifically restart the service you will not be able to navigate around the device.

My app has an exit button that is only accessible with a password. The button calls getActivity().finish(), which you will need to invoke the onDestroy method of the activity.

NOTE: I've read that on some devices the systemui services is not always 42, so your tablet may need a different number in the command.

public void hideNav()
{
    Log.v(tag, "hideNav");
      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("service call activity 42 s16 com.android.systemui\n");

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

      }
      catch (Exception e)
      {
          Log.e(tag, "hideNav " + e.getMessage());
      }

}

public void showNav()
{
    Log.v(tag, "showNav");

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

         DataOutputStream os = new DataOutputStream(p.getOutputStream());
         os.writeBytes("am startservice -n com.android.systemui/.SystemUIService\n");

         // Close the terminal
         os.writeBytes("exit\n");
         os.flush();
         p.waitFor();
    }catch (IOException e) {
        e.printStackTrace();
        Log.e(tag, "showNav " + e.getMessage());
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        Log.e(tag, "showNav " + e.getMessage());
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top