Allow rotating the screen without crashing by overriding the Configuration changes.

Restarting the activity is not a choice on orientation changes.
This commit is contained in:
miterosan
2019-01-02 16:20:50 +01:00
parent 9fee939688
commit e1cce88ae5

View File

@@ -5,19 +5,25 @@ using Android.App;
using Android.OS;
using Android.Content.PM;
using Android.Views;
using System;
using Android.Runtime;
using Android.Content.Res;
namespace SampleGame.Android
{
[Activity(Label = "SampleGame", MainLauncher = true, ScreenOrientation = ScreenOrientation.Landscape, Theme = "@android:style/Theme.NoTitleBar")]
[Activity(Label = "SampleGame", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, MainLauncher = true, Theme = "@android:style/Theme.NoTitleBar")]
public class MainActivity : Activity
{
private SampleGameView sampleGameView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Window.AddFlags(WindowManagerFlags.Fullscreen);
Window.AddFlags(WindowManagerFlags.KeepScreenOn);
SetContentView(new SampleGameView(this));
SetContentView(sampleGameView = new SampleGameView(this));
}
}
}