MainActivity.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Android.App;
  2. using Android.Content.PM;
  3. using Android.OS;
  4. using Android.Views;
  5. using Microsoft.Xna.Framework;
  6. using MonoGameDistortionSample.Core;
  7. namespace MonoGameDistortionSample.Android
  8. {
  9. /// <summary>
  10. /// The main activity for the Android application. It initializes the game instance,
  11. /// sets up the rendering view, and starts the game loop.
  12. /// </summary>
  13. /// <remarks>
  14. /// This class is responsible for managing the Android activity lifecycle and integrating
  15. /// with the MonoGame framework.
  16. /// </remarks>
  17. [Activity(
  18. Label = "MonoGameDistortionSample",
  19. MainLauncher = true,
  20. Icon = "@drawable/icon",
  21. Theme = "@style/Theme.Splash",
  22. AlwaysRetainTaskState = true,
  23. LaunchMode = LaunchMode.SingleInstance,
  24. ScreenOrientation = ScreenOrientation.SensorLandscape,
  25. ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden
  26. )]
  27. public class MainActivity : AndroidGameActivity
  28. {
  29. private MonoGameDistortionSampleGame _game;
  30. private View _view;
  31. /// <summary>
  32. /// Called when the activity is first created. Initializes the game instance,
  33. /// retrieves its rendering view, and sets it as the content view of the activity.
  34. /// Finally, starts the game loop.
  35. /// </summary>
  36. /// <param name="bundle">A Bundle containing the activity's previously saved state, if any.</param>
  37. protected override void OnCreate(Bundle bundle)
  38. {
  39. base.OnCreate(bundle);
  40. _game = new MonoGameDistortionSampleGame();
  41. _view = _game.Services.GetService(typeof(View)) as View;
  42. SetContentView(_view);
  43. _game.Run();
  44. }
  45. }
  46. }