Example #1
0
 public static void AlertMessage(string message, string title = "Error",
                                 string positive = null, string negative = null,
                                 Action <ActionType> callback = null)
 {
     try
     {
         SMainActivity.Instance.RunOnUiThread(() => SAlertDialogUtil.ShowDialog(message, title, positive, negative, callback));
     }
     catch (Exception)
     {
         // ignored
     }
 }
Example #2
0
        protected override void OnCreate(Bundle bundle)
        {
            MainActivity.instance = this;
            base.RequestWindowFeature(WindowFeatures.NoTitle);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
            {
                this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
            }

            this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
            this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);

            SMainActivity.Instance = this;
            try
            {
                File errorLog = this.FilesDir.ListFiles().FirstOrDefault(f => f.IsDirectory && f.Name == "error")?.ListFiles().FirstOrDefault(f => f.Name.EndsWith(".dat"));
                if (errorLog != null)
                {
                    try
                    {
                        Handler handler = new Handler((msg) => throw new RuntimeException());
                        SAlertDialogUtil.ShowDialog(System.IO.File.ReadAllText(errorLog.AbsolutePath), "Crash Detected", null, null, callback: (type =>
                        {
                            errorLog.Delete();
                            handler.SendEmptyMessage(0);
                        }));
                        try
                        {
                            Looper.Prepare();
                        }
                        catch (Exception) { }
                        Looper.Loop();
                    }
                    catch (Exception) { }
                }
                Type[] services = { typeof(Microsoft.AppCenter.Analytics.Analytics), typeof(Microsoft.AppCenter.Crashes.Crashes) };
                AppCenter.Start(Constants.MicrosoftAppSecret, services);
                AppCenter.SetUserId(Constants.ApiVersion.ToString());
            }
            catch
            {
                // ignored
            }
            base.OnCreate(bundle);
            this.CheckAppPermissions();
        }