I have a fullscreen activity, with no configChanges set in AndroidManifest.xml so that the system recreates the activity on orientation change. Everything works fine here, except that intermittently, an orientation change seems to cause the app to exit fullscreen mode and bring the system ui back in.
I have code to re-enter fullscreen when this happens, but I'd like to prevent it from coming out of fullscreen to begin with. I'm wondering why this may be happening?
I have also observed that this only happens when the debuggable flag is set to false in build.gradle for the build config (release or debug)
Activity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// initial fullscreen mode before content loads
enterFullscreenMode()
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
// not full screen
Handler().postDelayed({
enterFullscreenMode()
}, 800L)
}
}
}
private fun enterFullscreenMode() {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
}