I have applied windowInset Listener on the window.decorview to hide the bottom navigation bar and applied transiennt system bar behaviors, basically the immersive mode look, the immersive mode gets applied successfully and works fine
fun setWindowInsetListenerForImmersiveView() {
//! set immersive mode:
val windowInsetsController =
WindowCompat.getInsetsController(window, window.decorView)
// Configure the behavior of the hidden system bars.
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
// the system bars are hidden.
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { view, windowInsets ->
if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())) {
windowInsetsController.hide(WindowInsetsCompat.Type.navigationBars())
}
ViewCompat.onApplyWindowInsets(view, windowInsets)
}
}
but then when the listener is still active and I change a property of the window later say add the following flag:
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
suddenly the app becomes un-useable in some devices for example:
Redmi 10A
Huawei P20 Lite
Honor 6X
Oppo A15s
as we tap on the screen, the bottom navigation bar appears and then hides automatically and our touch or action is dismissed.
unable to get the reason behind this, just this when I apply log, the listener is triggered again and again.
Followed through the articles and they say that the windowInsetsListener can trigger again and again and this is its normal behavior but unable to understand why the bottom navigation bar keeps comming again and again once hidden.