I have an App containing a toggle FullScreen function.
It did success to toggle fullscreen using the following code.
if (tofull) {
if (Build.VERSION.SDK_INT < 16) {
Log.i("toggleFullScreen", "API<16");
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
Log.i("toggleFullScreen", "API>=16");
View decorView = getWindow().getDecorView();
// Hide the status bar.
// int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
} else {
if (Build.VERSION.SDK_INT < 16) {
Log.i("toggleFullScreen", "API<16");
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
Log.i("toggleFullScreen", "API>=16");
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
decorView.setSystemUiVisibility(uiOptions);
}
}
It can hide status bar after toggled to fullscreen mode.
However, when I pressed hardware menu key button (I have an options menu which will show up after menu key pressed), the status bar comes out. And status bar does not hide again.
What will be the possible reason for this problem exists?
Could anyone solve it(make the status bar hide again automatically)?