14

I want to hide system bar for tablet device. I searched a lot but not succeed. I added image for it.

I found some solution like

View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); 

but I dont know how to use it enter image description here

And I know that is possible as http://forum.xda-developers.com/showthread.php?t=1228046 Can any one know how to do this ?

Charles
  • 50,943
  • 13
  • 104
  • 142
Chirag Patel
  • 11,416
  • 3
  • 26
  • 38

11 Answers11

7

Code snippet to show/hide status bar on rooted android tablets

To hide:


            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 (Exception e) {
                Log.w("Main","Failed to kill task bar (1).");
                e.printStackTrace();
            }
            try {
                proc.waitFor();
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (2).");
                e.printStackTrace();
            }

To show:


            Process proc = null;
            try {
                proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "am startservice -n com.android.systemui/.SystemUIService" });
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (1).");
                e.printStackTrace();
            }
            try {
                proc.waitFor();
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (2).");
                e.printStackTrace();
            }
Basher51
  • 1,319
  • 1
  • 17
  • 28
  • Using the command `service call activity 42 s16 com.android.systemui` via the adb shell, it works. When using the code you posted above it won't hide the bars. Do I need any additional setup/permissions for my app to execute this? – taymless Apr 22 '14 at 09:13
  • @taymless: Your device should be rooted and your app should have access to su permissions.Besides these, I did not have any other setting set to achieve the above. – Basher51 Apr 22 '14 at 09:40
  • Thanks. Not sure if this a problem with my device, but it's not asking for the `su` permission. I used this method with the hide/show commands you posted instead, and it worked. http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/. – taymless Apr 23 '14 at 09:45
4

Finally after searching lots of time I got some alternativ for my requirement.

I know this is not a good idea for a programmer to back off from this situation but for my time limit I used this way...

I found this link and application which fullfil my requirement

http://www.42gears.com/blog/2012/04/how-to-hide-bottom-bar-in-rooted-android-3-0-tablets-using-surelock/

please visit this once if you want this type of requirement in your application ....

Thanks to all for helping me in my problem...

Chirag Patel
  • 11,416
  • 3
  • 26
  • 38
  • 1
    @chirag-saga Isn`t SureLock a paid app? I think a good alternative is HideBar - https://github.com/ppareit/HideBar (It also requires root as well as BusyBox) – ılǝ Nov 17 '12 at 15:46
2

It is not possible to hide the system bar. There is nothing in the API that allows for it. This is because the user always needs access to the home and back keys in case the app freezes or does something goofy where the user just needs to get out of the app. You can only hide the action bar.

Andi Jay
  • 5,882
  • 13
  • 51
  • 61
  • Actually, there is a way to temporarily hide the system bar on tablets, at least on Jelly Bean, but the bar returns as soon as the user taps the screen. – CommonsWare Aug 14 '12 at 18:41
  • Ooops, sorry -- that's only for handsets. For some reason, I thought it worked on tablets as well. I was thinking of `SYSTEM_UI_FLAG_HIDE_NAVIGATION`. My apologies. – CommonsWare Aug 14 '12 at 18:51
  • 3
    AndiJay - That is the correct reason for normal consumer use. However there is a rising demand in the corporate world for using Android Tablets as mini Kiosks. Right now the only way to do that is by rooting the tablet. I would love to see Android add a "Kiosk" mode for this situation though. Anyway, your answer is correct but not for every situation. When a tablet is being used for a kiosk then the user should not have access to anything except the single app. – Justin Nov 15 '12 at 13:32
  • Interesting point. I wonder if Google will ever official support a way to remove the system bar then. They could go the way of windows 8 where you have to do a swipe gesture from one of the edges of the screen. – Andi Jay Nov 17 '12 at 03:59
1

There is a workaround to disable menu bar in all most all tablets without rooting. But this is bit tricky, but it works clean. Several well known apps in the market at the moment using this strategy to achieve this disable menu bar feature for their apps.

  • Grant admin privilege.
  • Set password & lock the device using device admin profile api
  • Then load what ever the UIs on top of the native lock screen. (Of course this will show background lock screen whenever a transition happens between activities. But if logic is organized well, then it will be smooth & less noticed by the user)
  • When need to enable back, reset password to "" using resetPassword("", 0) of device policy manager object.
M P Mathugama
  • 1,418
  • 1
  • 20
  • 31
1
var width = innerWidth;

var height = innerHeight;

I think this code will help for you.its not hide the tablet bar but your application fit on any device you can use this (I used this code in javascript for cord ova mobile application)

Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
Sahal Zaman
  • 235
  • 1
  • 2
  • 10
  • 1
    This does not answer the OP's question, as you yourself mention ("its not hide the system bar"). If you have annotations to a post, please post a comment. You can do so as soon as you have earned the privilege to *post anywhere* – T3 H40 Nov 11 '15 at 08:27
1

You just need combination of SYSTEM_UI_FLAG_IMMERSIVE_STICKY | SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN. For example, if you use opengl and glSurfaceView is you surface:

glSurfaceView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

Swipe at bottom to see the bottom bar, it will hide again after few seconds.

user2626972
  • 539
  • 2
  • 7
  • 14
0

I believe its the same for all android devices.

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);

I also found another solution but this of course is just a separate app called surelock.

http://onkarsingh.sys-con.com/node/2184158

EDIT:

The above code doesn't hide the Tablet Bar. I'll leave my answer up for those looking to hide the System Bar in another Android Device.

Nate-Wilkins
  • 5,364
  • 4
  • 46
  • 61
  • Yes CommonsWare is right I tried also this not working for tablets. – Chirag Patel Aug 14 '12 at 19:12
  • 1
    what doesn't work? The code or SureLock? SureLock has two options - `Hide Bottom Bar` and `Disable Bottom Bar`. First option requires rooting. Second on works without rooting!! – PC. Aug 25 '12 at 03:03
  • My code example doesn't but SureLock says it does. Can't say I've used it though. – Nate-Wilkins Aug 25 '12 at 18:27
0

You can't hide it but you can simply disable it, except home. Try this link. . Using SYSTEM_UI_FLAG_LOW_PROFILE you can dim your system bar and using onWindowFocusChanged() can take the focus and collapse it.

Community
  • 1
  • 1
PiyushMishra
  • 5,743
  • 6
  • 37
  • 57
0

I found a trick on a galaxy tab for use it as a kiosk according to the developer guide of Samsung

You can ask your app to be over the lock system and ask the return button to go back to a start activity/view of your app. I done this for a web View app

    @Override
    public void onBackPressed() {
        //here asking to go back to home page
        mWebView.loadUrl(mHomepageUrl);
    }

for asking to stay up from the lock system, on the onCreate method :

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

and then when you click on the power button twice , you found back your application , and only the back button is active on the status bar

So the only way is to reboot the tablet (and so you can use the classic lock system with a code to open tablet)

Can be useful if the power button is not accible by visitor , or if your are the only one who have the unlock code

Philippe T.
  • 1,182
  • 7
  • 11
-1

// Put code on onCreate method of your activity / fragment

@Override
        @SuppressLint("NewApi")
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            getSupportActionBar().hide();
            setContentView(R.layout.activity_main);

              getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }
Hiren Patel
  • 52,124
  • 21
  • 173
  • 151
-1

In order to create a Kiosk app in android you need the following: - Override the onkeydown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode==KeyEvent.KEYCODE_BACK || keyCode==KeyEvent.KEYCODE_HOME){


        startActivity(new Intent(this,MainActivity.class));
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

Then make your activity a launcher activity in order to override the home button. (in the manifest)

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

No need for weird locker apps that asks a million permissions. You don't have to root your phone.