Android, GL, screen size in IMMERSIVE MODE

android, android-4.4-kitkat, android-gui, opengl-es

Solution

Good article but still not enough. http://developer.android.com/training/system-ui/immersive.html

Right now we get screen size with

public void onSurfaceChanged(GL10 gl, int width, int height) {

and if height decreased then we enable immersive mode again with 1 second delay. This works but hacky and I look for canonical solution myself.

I am afraid it is just buggy in KitKat. I do not any famous title that implemented immersive mode. (except our app of course )))

Problem

I am developing with Nexus 4 KitKat 4.4 and trying to add `IMMERSIVE MODE` to my game. I need screen height to set `glViewport` correctly. Previously I used ``` @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public static int getScreenHeight() { if (Main.m_activity == null) return -1; Display display = Main.m_activity.getWindowManager() .getDefaultDisplay(); int height = -1; if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){ //width = display.getWidth(); // deprecated height = display.getHeight(); // deprecated }else{ Point size = new Point(); display.getSize(size); height = size.y; } return height; } ``` It does not return the real height of screen in `IMMERSIVE MODE`. So I started to use values from ``` private static class Renderer implements GLSurfaceView.Renderer { public void onSurfaceChanged(GL10 gl, int width, int height) { ``` and it worked fine when app starts. If I press home button and return to home screen and then back to game `onSurfaceChanged` get called again but with old wrong values (non-immersive mode screen size, smaller, regular) IMMERSIVE SCREEN size is 800x1280 REGULAR size is 800x1184 When I get regular size and set it in `glViewport` then I get black line in top of screen. PS Also `IMMERSIVE MODE` is lost when I press volume buttons. PS2 I have following method impl. It does not help to handle screen/window resize. ``` @Override public void onWindowFocusChanged(boolean hasFocus) { ```

Original source