How to enable Immersive Mode in Android?


#1

Hey there, I’m looking for how to enable immersive mode in an OpenFrameworks android app.

This is a description of immersive mode:
https://developer.android.com/training/system-ui/immersive.html

I’m doing this inside my main.cpp:

ofAppAndroidWindow * androidWindow = new ofAppAndroidWindow();
androidWindow->setFullscreen(true);

And this isn’t setting immersive mode as I expect.
Thank you,
Jason


#2

bump

From https://developer.android.com/training/system-ui/immersive:

To enable immersive mode, call setSystemUiVisibility() and pass the SYSTEM_UI_FLAG_IMMERSIVE flag in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION.

but I’m not sure how or where to put this Java.


#3

I found a solution or a workaround at least: in the OFActivity.java file of the project in the onCreate method it works to add

   getWindow().getDecorView()
                .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + View.SYSTEM_UI_FLAG_IMMERSIVE);
    }