WebView: permanently disable status bar - android

I'm developing a one-view app which contains a fullscreen WebView. I started the project from a fullscreen template and added the code from both this and this official docs pages.
When the app is first started it works good and i obtain a fullscreen with no status bar. Problem is that when i exit the app (either opening the task manager or pressing the button that leads to the home) and then re-enter in it, the status bar is displayed and there's no way to hide it back if not closing and re-opening the app.
How can i fix this?
UPDATE
Here's the source code:
AndroidManifest.xml
FullscreenWebView.java
activity_fullscreen_web_view.xml
As already told, I haven't made much customization from the standard template of Android Studio.
The fullscreen code I've added is this, anyway:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
setContentView(R.layout.activity_fullscreen_web_view);

Related

Hide navigation bars on Android when reopening app

I'm trying to hide the top and bottom navigation bars on Android devices when I run my app. Right now, I have modified my "onWindowFocusChanged" and "onCreate" methods to have the following code fragment:
final int screen =
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_FULLSCREEN;
getWindow().getDecorView().setSystemUiVisibility(screen);
However, when I go back to the home screen on Android without closing the app, reopen my app, and then try to switch between pages on my app, the navigation bar briefly appears and then disappears between these switches. I assume this is because the above methods are not being accessed.
How can I make sure that even when a user abruptly switches out of my app and then back into it, that the navigation bar will not briefly reappear when switching pages as a result?
Thanks for the help.
You can look at the guide here: https://developer.android.com/training/system-ui/navigation
You need to add the code to three places:
onWindowFocusChanged, onCreate and onResume

Remove system menu bar from react native android app

My problem is simple and I have been unable to find a solution. The menu bar is very annoying in my app and I am hoping that there is a way to remove it.
Looking at Hiding the Navigation Bar I found this:
You can hide the navigation bar on Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
I do not know if that's exactly what you was looking for, but you can test it.
I suggest you read more about native modules, it enables you to write native code and access it from JS.
http://facebook.github.io/react-native/docs/native-modules-android.html#content
Also the StatusBar module is very similar to what you want to do here, you can have a look at the source.
https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java#L110

Button does not react to first tap in fullscreen mode

On the first start of my app I start an Intro-Activity in fullscreen with hidden navigation bar (black bar at the bottom) with:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
The Activity contains a Button to close it.
My problem is: with hidden navigation bar, the first tap on the close-button does not trigger the button, but reveals the navigation bar, only the second tap triggers the button.
Is there a way how I can close the Activity on first button tap?
The answer is described here- https://developer.android.com/training/system-ui/immersive.html. There's a new flag SYSTEM_UI_FLAG_IMMERSIVE that allows this. Unfortunately its KitKat and above only- older phones do not have the capability.

Hide Bottom Option Bar in Android

I want to hide Bottom Option Bar in Android. I don't know whether we call it Option Bar it or not.
Please check it out Image below : Tell me if we call it something else. It is in bottom.
Now, I want to hide it. How to do it ?
It's called navigation bar, the reason for it only having the options button is probably because your device has hardware buttons for home and back, that's why it looks like an options button only bar.
Refer to the docs for hiding it, although it will only work for versions supporting it.
For 4.0+
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

Hide status bar when using a YoutubeFragment (YoutubePlayer android API)

I have a fullscreen project, and am hiding the statusbar using
getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
in the main activity's onCreate.
This works, and hides the status bar just fine, until I add a YoutubeFragment and play a video. The moment the video loads, the status bar drops down, very annoying. I tried setting the flags all over the onInitializationSuccess listener, but no dice. The documentation doesn't mention the status bar on any non-full screen layout changes at all: https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerFragment
Anyone any ideas?
Thanks in advance.
I don't know if you can put in manifest to hide action bar.
But try this function of Activity class
getActionBar().hide();
I was using a android 4.4.2 device to test with. With 4.1+ or higher there's another way to hide the status bar dynamically : http://developer.android.com/training/system-ui/status.html#41
//4.1+ Specific hiding of status bar
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
I do not have the problem with the status bar popping up when adding a YoutubeFragment. Why the old code didn't work with YoutubeFragments, or even setting the Theme to
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen"
, I have no idea though.

Categories

Resources