MainActivity.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Android.App;
  2. using Android.Content.PM;
  3. using Android.Widget;
  4. using Android.OS;
  5. using Android.Views;
  6. using AtomicEngine;
  7. namespace AtomicPlayer
  8. {
  9. [Activity(Label = "AtomicPlayer", MainLauncher = true,
  10. Icon = "@drawable/icon", Theme = "@android:style/Theme.NoTitleBar.Fullscreen",
  11. ConfigurationChanges = ConfigChanges.KeyboardHidden | ConfigChanges.Orientation,
  12. ScreenOrientation = ScreenOrientation.Landscape)]
  13. public class MainActivity : Activity
  14. {
  15. protected override void OnCreate(Bundle bundle)
  16. {
  17. base.OnCreate(bundle);
  18. var mLayout = new AbsoluteLayout(this);
  19. var surface = AndroidSDLSurface.CreateSurface(this, false, typeof(AtomicMain));
  20. mLayout.AddView(surface);
  21. SetContentView(mLayout);
  22. }
  23. protected override void OnResume()
  24. {
  25. AndroidSDLSurface.OnResume();
  26. base.OnResume();
  27. }
  28. protected override void OnPause()
  29. {
  30. AndroidSDLSurface.OnPause();
  31. base.OnPause();
  32. }
  33. public override void OnLowMemory()
  34. {
  35. AndroidSDLSurface.OnLowMemory();
  36. base.OnLowMemory();
  37. }
  38. protected override void OnDestroy()
  39. {
  40. AndroidSDLSurface.OnDestroy();
  41. base.OnDestroy();
  42. }
  43. public override bool DispatchKeyEvent(KeyEvent e)
  44. {
  45. if (!AndroidSDLSurface.DispatchKeyEvent(e))
  46. return false;
  47. return base.DispatchKeyEvent(e);
  48. }
  49. public override void OnWindowFocusChanged(bool hasFocus)
  50. {
  51. AndroidSDLSurface.OnWindowFocusChanged(hasFocus);
  52. base.OnWindowFocusChanged(hasFocus);
  53. }
  54. }
  55. }