"Immersive Mode" Android app. All documentation is deprecated

Viewed 1782

I'm trying to make my app run in fullscreen mode where the navigation bar and the status bar is hidden. All documentation I can find seems to be deprecated and the only one that I could find that seemed to not be deprecated in Kotlin is setDecorFitsSystemWindows(false) but that errors with

java.lang.NoSuchMethodError: No virtual method setDecorFitsSystemWindows(Z)V in class Landroid/view/Window; or its super classes (declaration of 'android.view.Window' appears in /system/framework/framework.jar!classes3.dex)

How do you make an app fullscreen now in Android Kotlin?

1 Answers

There are one alternative solution.

Update androidx.core library

implementation "androidx.core:core-ktx:1.5.0-alpha05"

Instead of

activity?.window?.setDecorFitsSystemWindows(false)

Use new api

activity?.window?.run{
     WindowCompat.setDecorFitsSystemWindows(this, false)
}
Related