protected override void OnCreate(Bundle savedInstanceState) { // The default current directory on android is '/'. // On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage. // In order to have a consistent current directory on all devices the full path of the app data directory is set as the current directory. System.Environment.CurrentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); base.OnCreate(savedInstanceState); SetContentView(gameView = new AndroidGameView(this, CreateGame())); UIVisibilityFlags = SystemUiFlags.LayoutFlags | SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen; Debug.Assert(Window != null); // Firing up the on-screen keyboard (eg: interacting with textboxes) may cause the UI visibility flags to be altered thus showing the navigation bar and potentially the status bar // This sets back the UI flags to hidden once the interaction with the on-screen keyboard has finished. Window.DecorView.SystemUiVisibilityChange += (_, e) => { if ((SystemUiFlags)e.Visibility != systemUiFlags) { UIVisibilityFlags = systemUiFlags; } }; if (Build.VERSION.SdkInt >= BuildVersionCodes.P) { Debug.Assert(Window.Attributes != null); Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges; } gameView.HostStarted += host => { host.AllowScreenSuspension.Result.BindValueChanged(allow => { RunOnUiThread(() => { if (!allow.NewValue) { Window.AddFlags(WindowManagerFlags.KeepScreenOn); } else { Window.ClearFlags(WindowManagerFlags.KeepScreenOn); } }); }, true); }; }
public AndroidGameHost(AndroidGameView gameView) { this.gameView = gameView; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(gameView = new AndroidGameView(this, CreateGame())); }
public AndroidGameHost(AndroidGameView gameView) { this.gameView = gameView; AndroidGameWindow.View = gameView; Window = new AndroidGameWindow(); }