SDL2 Code change to make Android really fullscreen

I’ve noticed that SDL is not completely full screen on Android, there’s a small bar at the top when the battery life etc can be displayed. (This a new thing since 2.0.4 I think)

To fix this problem I’ve removed some calls to window.addFlags and window.clearFlags.
This fixes the problem and my game now runs in proper full screen and will also recover just fine when it loses and regains focus.

Can anyone see why these lines were there in the first place?

See my changes below: ( ===> )

SDLActivity.java

case COMMAND_CHANGE_WINDOW_STYLE:
if (Build.VERSION.SDK_INT < 19) {
// This version of Android doesn’t support the immersive fullscreen mode
break;
}
if (context instanceof Activity) {
Window window = ((Activity) context).getWindow();
if (window != null) {
if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
window.getDecorView().setSystemUiVisibility(flags);
===> //window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
===> //window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
SDLActivity.mFullscreenModeActive = true;
} else {
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
window.getDecorView().setSystemUiVisibility(flags);
===> //window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
===> //window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
SDLActivity.mFullscreenModeActive = false;
}
}
} else {
Log.e(TAG, “error handling message, getContext() returned no Activity”);
}
break;

I don’t know why the lines are there, but if you look in the history the commit messages for those two lines are:

On Android show the system UI when an SDL window is windowed, hide the system UI when it’s fullscreen, like we do on iOS.

Deal with situations where the system UI is shown when the keyboard pops up (thanks Rachel!)

They seem intentional and I don’t see why removing them would help, since there doesn’t seem to be anything logically wrong with them. Probably some android quirk?
Using 2.0.10, creating a window with BORDERLESS and FULLSCREEN_DESKTOP flags, it worked fine on several devices I’ve tested. You should probably give it a quick search in the bug tracker(https://bugzilla.libsdl.org/) and if that doesn’t answer your question open a new bug with a minimal example project (with manifest and everything) and details of your system/device.

Thanks for the info.
I’ll give it a go here on some different devices. I’ll also see how it handles the virtual keyboard coming and going. It looks like those lines might be related to that.