I am trying to create a button where I can hide or show the status bar on my tablet.
I've put in the onCreate
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
and in the buttons show:
WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().setAttributes(attrs);
hide:
WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().setAttributes(attrs);
Any hints/tipps?
//edit
I've looked at this hint here: http://android.serverbox.ch/?p=306 and changed my code like this:
private void hideStatusBar() throws IOException, InterruptedException { Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"}); proc.waitFor(); } private void showStatusBar() throws IOException, InterruptedException { Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"}); proc.waitFor(); }
So if I click on my buttons an the methods are called I can see that something is happening because the app is waiting some seconds. I also looked into LockCat and see that something is happening.
show: http://pastebin.com/CidTRSTi hide: http://pastebin.com/iPS6Kgbp
If you want to bring the Notification Bar back, open Fullscreen: The One Immersive Mode again and tap "Hide Nothing." You can also tap the option next to "Fullscreen" to hide your Notification Bar and your Navigation Bar.
View decorView = getWindow(). getDecorView(); // Hide the status bar.
Do you have the fullscreen theme set in the manifest?
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
I don't think you'll be able to go fullscreen without this.
I would use the following to add and remove the fullscreen flag:
// Hide status bar getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // Show status bar getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With