1
votes

Goodmorning, i'm trying to hide the navigation bar on my app android. i have device admin permission,i have created my kiosk app but i need to hide the navigation bar. in this moment i have no home button but i have back button.if i press on it the tablet say u can't exit app for device admin. to block the bar i use this

startlocktask()

i have tried devicePolicyManager.SetStatusBarDisabled() but this hide status not home

i have this code for hide navigation bar

 View decorView = Window.DecorView;
            var uiOptions = (int)decorView.SystemUiVisibility;
            var newUiOptions = (int)uiOptions;
            newUiOptions |= (int)SystemUiFlags.LowProfile;
            newUiOptions |= (int)SystemUiFlags.Fullscreen;
            newUiOptions |= (int)SystemUiFlags.HideNavigation;
            newUiOptions |= (int)SystemUiFlags.Immersive;
            newUiOptions |= (int)SystemUiFlags.ImmersiveSticky;
            decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;

but when someone drag up the bottom bar this appear with only back button.i don't want that the user can see the navigation bar. can someone help me?

thanks regards

1

1 Answers

0
votes

This may help https://stackoverflow.com/a/19201933/4172545

This is the answer from the link:

Ok, if anyone is interested, I've solved my problem this way: Added a transparent view to the window manager, with 1px width and match_parent height. Then added a global layout listener to this view, and everytime there's a change on the layout, I check the position of this view on screen. If it's Y is 0, then the status bar is not visible, so a full screen app must be running. This works even better than the native View.OnSystemUiVisibilityChangeListener because it seems there are some apps that somehow don't trigger that method (like the new yahoo weather).

So with that you can have an event fire and when the Navigation bar is visible hide it, by calling your code again that you originally used to hide it.

Here is a little more concise way to write it :

 Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); 

 Window.DecorView.SystemUiVisibility = (StatusBarVisibility) 
                          (SystemUiFlags.LowProfile 
                          | SystemUiFlags.Fullscreen 
                          | SystemUiFlags.HideNavigation
                          | SystemUiFlags.Immersive
                          | SystemUiFlags.ImmersiveSticky);