MainActivity.cs 851 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using Android.App;
  3. using Android.Content;
  4. using Android.Content.PM;
  5. using Android.Runtime;
  6. using Android.Views;
  7. using Android.Widget;
  8. using Android.OS;
  9. using Xamarin.Forms.Platform.Android;
  10. namespace XamarinInsights.Android
  11. {
  12. [Activity (Label = "XamarinInsights.Android.Android", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
  13. public class MainActivity : AndroidActivity
  14. {
  15. protected override void OnCreate (Bundle bundle)
  16. {
  17. base.OnCreate (bundle);
  18. if (string.IsNullOrEmpty (App.InsightsApiKey))
  19. throw new Exception ("A Xamarin Insights Api key is required");
  20. Xamarin.Insights.Initialize (App.InsightsApiKey,this);
  21. Xamarin.Forms.Forms.Init (this, bundle);
  22. App.RunOnMainThread = (a) => this.RunOnUiThread (a);
  23. SetPage (App.GetMainPage ());
  24. }
  25. }
  26. }