mercredi 25 février 2015

Hide the Navigation Bar permanently on certain Activity under Android 4.2.2 (framework editable if necessary)


Is it possible to permanently hide Navigation Bar on certain Activity under Android 4.2.2(Jelly Bean)?


Please note that I have a custom android device and can modify its framework source if necessary.


Using Immersive mode under Android 4.4+ could be a solution in my opinion but that is not the option that I can have.


I have tried it with the following code snippet. but once I touch the screen, the nav bar shows up and will not disappear even I call SYSTEM_UI_FLAG_HIDE_NAVIGATION.



window.getDecorView().setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
// The system bars are visible.
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | 0x4);
}
else {
// The system bars are NOT visible.
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
});


Hiding Navigation Bar permanently on application level would be the best, but I can modify its framework source if necessary (such as PhoneWindowManager.java).





Aucun commentaire:

Enregistrer un commentaire