Chirag Patel
Chirag Patel

Reputation: 11508

Hide Tablet system bar

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 ?

Upvotes: 14

Views: 33523

Answers (11)

user2626972
user2626972

Reputation: 589

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.

Upvotes: 1

Sahal Zaman
Sahal Zaman

Reputation: 255

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)

Upvotes: 1

Digital Peppa
Digital Peppa

Reputation: 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.

Upvotes: -1

Hiren Patel
Hiren Patel

Reputation: 52800

// 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);
        }

Upvotes: -1

Philippe T.
Philippe T.

Reputation: 1192

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

Upvotes: 0

Basher51
Basher51

Reputation: 1329

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();
            }

Upvotes: 7

M P Mathugama
M P Mathugama

Reputation: 1418

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.

Upvotes: 1

PiyushMishra
PiyushMishra

Reputation: 5773

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.

Upvotes: 0

Chirag Patel
Chirag Patel

Reputation: 11508

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...

Upvotes: 4

Nate-Wilkins
Nate-Wilkins

Reputation: 5502

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.

Upvotes: 0

jsrz
jsrz

Reputation: 6052

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.

Upvotes: 2

Related Questions