Hide Tablet system bar

安稳与你 提交于 2019-11-27 04:34:22

问题


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

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


回答1:


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



回答2:


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




回答3:


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.




回答4:


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.



回答5:


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)




回答6:


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.




回答7:


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.




回答8:


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.




回答9:


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




回答10:


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



回答11:


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.



来源:https://stackoverflow.com/questions/11958034/hide-tablet-system-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!