Exemple #1
0
        /**
         * 当UncaughtException发生时会转入该函数来处理
         */
        public void UncaughtException(Thread thread, Throwable ex)
        {
            if (!handleException(ex) && mDefaultHandler != null)
            {
                //如果用户没有处理则让系统默认的异常处理器来处理
                mDefaultHandler.UncaughtException(thread, ex);
            }
            else
            {
                DownloadBookService.cancel(); // 取消任务
                LogUtils.i("取消下载任务");
                new Thread(() => {
                    Looper.Prepare();
                    ToastUtils.showSingleToast("哎呀,程序发生异常啦...");
                    Looper.Loop();
                }).Start();

                try {
                    Thread.Sleep(3000);
                } catch (InterruptedException e) {
                    LogUtils.e("CrashHandler.InterruptedException--->" + e.ToString());
                }
                //退出程序
                Process.KillProcess(Process.MyPid());
                JavaSystem.Exit(1);
            }
        }
 private static void SetExitAction()
 {
     App.ExitApplication = () =>
     {
         Process.KillProcess(Process.MyPid());
     };
 }
Exemple #3
0
 /// <summary>
 /// 退出APP
 /// </summary>
 public void ExitApp()
 {
     RemoveAllActivity();
     Android.OS.Process.KillProcess(Process.MyPid());
     Xamarin.Forms.Application.Current.Quit();
 }