I am writing an Android app which uses immersive mode quite extensively (a kiosk application to be precise). I however am noticing that every time it switches between activities the navigation bar pops into view for a short instant (not long enough to be useful for a normal user, but just long enough for curious users to push the home button and easily quit the Kiosk application).
Example of how I am setting my system visibility flags:
@Override
public boolean onTouchEvent(MotionEvent event) {
setImmersiveMode();
return super.onTouchEvent(event);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setImmersiveMode();
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
setImmersiveMode();
return super.dispatchTouchEvent(ev);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
setImmersiveMode();
}
}
protected void setImmersiveMode() {
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_STICKY
| View.INVISIBLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
and I start my activity like so:
Intent intent = new Intent(MyParentActivity.this, MyNextActivity.class);
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap.put("my_var", "some useful stuff");
intent.putExtra(EXTRA_MESSAGE, hashMap);
startActivity(intent);
During the time in which the current activity goes blank and the next activity starts loading the navigation buttons and action bar appear. Once the next activity loads it calls the setImmersiveMode() method and effectively sets things back to the desired visibility states. I can not determine a way to switch activities without these Android UI elements blinking into existence.
Has anyone ever run up against this issue before with any resolve?
Notes:
- The devices I use only have "soft buttons".
- I am running my app on an Android 4.4.2 device.
- I have done some searching on the net but was unable to find anything sufficient to resolving this.
- I am relatively new to Android programming.
And thanks for any assistance.