I have been racking my brain a week now trying things left and right and I cannot seem to find the answer. I might actually have more questions.
We have an application that uses a Unity view in one of its activities to present some graphics. As this is a normal app and not a game we want to remove immersive mode and fullscreen so we can get back the system bars (status and navigation)
Now since recent versions of Unity they added the Start in fullscreen mode
option in the player settings for Android. The problem is that the above option brings back only the navigation bar.
The next step was to try and bring back with some native Android coding. So basically this:
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
does the work and brings back the status bar.
Now that worked like a charm until I went to a tall aspect ratio (18.5:9 - Pixel 3 XL - Android 9) device.
If I go about it simply with the Unity fullscreen option the graphics scale nicely but I have no status bar, something that is even more apparent to notched phone:
If I remove the fullscreen flag from Android then I get my status bar back but the rendering breaks:
The ???
is the black area that appears.
Sorry, I cannot show you the actual app.
Now, I played around with other flags of the so called "immersive mode":
// When init of Unity
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.showSystemUi();
this.addUiVisibilityChangeListener();
// What the above does
private static int getLowProfileFlag() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN : View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
private void showSystemUi() {
this.mUnityPlayer.setSystemUiVisibility(this.mUnityPlayer.getSystemUiVisibility() & ~getLowProfileFlag());
}
private void addUiVisibilityChangeListener() {
this.mUnityPlayer.setOnSystemUiVisibilityChangeListener(visibility -> RadarOverviewActivity.this.showSystemUi());
}
and under circumstances a similarly sized black bar appears above the graphics area.
Finally when the black bars are there the native UI also breaks. For the bottom bar there should be some tooling there that gets pushed up where the graphics actually start. The bottom black bar is part of UnityPlayer as touching there can actually cause interaction with the graphics. The top bar, when it is there, is even weirder. That area is actually where the native toolbar should be and in a way is. It cannot be seen but touching there triggers the UI events!!! It looks like the Unity view cannot place itself properly when not in fullscreen, as the Native UI initially appears correctly but when Unity kicks in goes all weird. To point the attention once more. This happens only in tall aspect devices. 16:9 devices seem to have no issues.
So the main question is, How do I take the app out of Fullscreen, with the status bar appearing and not breaking the Unity rendering in tall aspects?
I am not 100% sure of the why but it seems like other people had this issue and specifically with Android 9. Updating to Unity 2019.1.5f1 actually solved this issue for me.
I am posting this answer for someone else who might need it but not accepting it as of yet. I want to first make sure what was the issue point. I will update accordingly.