I was wondering if there is a way to hide an Android device's soft keys (status and navigation bars) right when an app launches? Take, for instance, a game that initially displays a black screen while hiding the soft keys in runtime prior to the brand, title, and main menu screen.
I included the following code snippet in my MainActivity, and when the app launches, I initially see a white screen with the soft keys in runtime for about a second and then the softkeys later disappear when MainActivity's thread finishes running:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
Thanks a bunch.
* UPDATE AS OF 1/19/2017: * After including:
<item name="android:windowFullscreen">true</item>
... into the app's theme, only the status bar hides on time as opposed to the navigation bar. My second post - Hiding the navigation bar immediately on app launch