Ejemplo n.º 1
0
 private static void SetExitAction()
 {
     App.ExitApplication = () =>
     {
         Process.KillProcess(Process.MyPid());
     };
 }
Ejemplo n.º 2
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);
            }
        }