Hiding the Navigation Bar - Android Training -
I am currently going through Android training, because I am trying to hide the navigation bar properly. It says:
You can hide the navigation bar by using Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and status bar:
Then they provide a code sample.
see decorView = getWindow (). GetDecorView (); // Hide both the navigation bar and status bar // SYSTEM_UI_FLAG_FULLSCREEN is available only on Android 4.1 and higher, but as a general rule, you should design your app to hide the status bar whenever you hide the navigation bar I Int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; DecorView.setSystemUiVisibility (uiOptions);
As you can see that the SYSTEM_UI_FLAG_FULLSCREEN
flag is only available in 4.1 but they say that this block of code is for 4.1. Will this not cause the application to crash? Does my block's code look more like:
see decorView = getWindow (). GetDecorView (); If (Build.VERSION.SDK_INT == 14 || Build.VERSION.SDK_INT == 15) {int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; DecorView.setSystemUiVisibility (uiOptions); } And if (Build.VERSION.SDK_INT> = 16) {int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; DecorView.setSystemUiVisibility (uiOptions); }
Is not it the reason to crash?
Not necessarily
View values such as
. YSTEM_UI_FLAG_FULLSCREEN
arefixed final int
. Their actual numerical value is put into the APK, not a symbol that is seen on the runtime. Therefore, you will not crash just to keep numbers there.what
setSystemUiVisibility ()
will then when the unknown flag is set, however, it may be different, usually, it will be okay because the platform is usually only the platform's API Masks the flag up to the bit limit used for the level, and therefore what is happening in high-order bits is irrelevant though, I did not specifically try it in case ofsetSystemUiVisibility ()
But, if Google's damp Not running this show is that it 4.0, and if you run it on 4.0 without any problems, then you should be fine.
Comments
Post a Comment