Navigation Bar visible after interstitial advert

My game permanently disables the navigation bar but it reappears when an interstitial advert is shown, which would be ok but it then remains on the screen when the game resumes and gets in the users way. I’ve noticed on other peoples games it is hiding again as soon as the advert is shown.

Does anyone know how I resolve this?

using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Views;
using Microsoft.Xna.Framework;

namespace My_Game
{
[Activity(
Label = “My Game”,
MainLauncher = true,
Icon = “@drawable/Icon”,
AlwaysRetainTaskState = true,
LaunchMode = LaunchMode.SingleInstance,
ScreenOrientation = ScreenOrientation.SensorLandscape,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize
)]
public class Activity1 : AndroidGameActivity
{
private Game1 _game;
private View _view;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        _game = new Game1();
        _view = _game.Services.GetService(typeof(View)) as View;
        RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;
        SystemUiFlags flags = SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky | SystemUiFlags.Immersive; Window.DecorView.SystemUiVisibility = (StatusBarVisibility)flags; Immersive = true;
        SetContentView(_view);
        _game.Run();
    }
}

}

I think you need the hide system UI in your OnResume. Give this a try in your android activity.

        protected override void OnResume()
        {
            base.OnResume();

            // When we resume (which also seems to happen on startup), hide the system UI to go to full screen mode.
            HideSystemUI();
        }

        private void HideSystemUI()
        {
            // Apparently for Android OS Kitkat and higher, you can set a full screen mode. Why this isn't on by default, or some kind
            // of simple switch, is beyond me.
            // Got this from the following forum post: http://community.monogame.net/t/blocking-the-menu-bar-from-appearing/1021/2
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
            {
                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.ImmersiveSticky;

                decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;

                this.Immersive = true;
            }
        }
1 Like

That worked perfectly. Thank you so much for your help.

1 Like