I need to hide navigation bar in Xamarin Forms application permanently. Application is destinated to be installed on Android device. I mean, device with will be open to public (like restaurant's kiosk). I want to start my application only and prevent user from going to the system.
I read this: https://developer.android.com/training/system-ui/navigation
I tried this immersive sticky mode. At start status bar and navigation bar are hidden. When I swipe at top or at bottom, the navigation bar appears. How to prevent or disable it?
I read about rooting device and uninstall UISystem.apk and boot indicated app but I think the warranty for device will be lost. Is there another way?
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
HideSoftwareMenuBars();
LoadApplication(new App());
}
public override void OnWindowFocusChanged(bool hasFocus)
{
base.OnWindowFocusChanged(hasFocus);
if (hasFocus)
HideSoftwareMenuBars();
}
protected override void OnResume()
{
base.OnResume();
HideSoftwareMenuBars();
}
private void HideSoftwareMenuBars()
{
int uiOptions = (int)Window.DecorView.SystemUiVisibility;
uiOptions |= (int)SystemUiFlags.LayoutStable;
uiOptions |= (int)SystemUiFlags.LayoutHideNavigation;
uiOptions |= (int)SystemUiFlags.LayoutFullscreen;
uiOptions |= (int)SystemUiFlags.LowProfile;
uiOptions |= (int)SystemUiFlags.HideNavigation;
uiOptions |= (int)SystemUiFlags.Fullscreen;
uiOptions |= (int)SystemUiFlags.ImmersiveSticky;
this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;
}