I have an android app which uses immersive mode for all activities - so its a full fullscreen app.
I have a BaseActivity class from which all other activities extend. In this activity I call the following to enable fullscreen/immersive
HelmiBlankActivity:
private boolean apiLowerImmersive = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
apiLowerImmersive = true;
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus && !apiLowerImmersive ) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
}
In activities it works great, the problem is: When opening a new activity (per intent) the actionbar/titlebar are displayed for a short time and then hidden again - which seems kind of laggy/buggy.
The Application also has a theme: styles.xml:
<style name="FullscreenTheme" parent="android:Theme.Holo.Light">
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
I have tried applying the android:Theme.Holo.Light.NoActionBar as well - no success during transitions. I could not find anything on stackoverflow (which btw is a great community and has helped me with many problems) or anywhere else on the internet and would appreciate your help.
If you put this snippet into onCreate() method your activities will open with the bars already hidden.
You can also add conditions for older SDKs. The only problem I've got with this setup is the fact that once i swipe down to show bars, they won't hide again...