🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
UncaughtHandler函数的代码如下: **RuntimeInit.java::UncaughtHandler** ~~~ privatestatic class UncaughtHandler implements Thread.UncaughtExceptionHandler{ publicvoid uncaughtException(Thread t, Throwable e) { try { if (mCrashing) return; mCrashing = true; //调用AMS的handleApplicationCrash函数。第一个参数mApplicationObject其实 //就是前面经常见到的ApplicationThread对象 ActivityManagerNative.getDefault().handleApplicationCrash( mApplicationObject, new ApplicationErrorReport.CrashInfo(e)); } ...... finally{ //这里有一句注释很有意思:Try everything to make surethis process goes //away.从下面这两句调用来看,该应用进程确实想方设法要离开Java世界 Process.killProcess(Process.myPid());//把自己杀死 System.exit(10);//如果上面那句话不成功,再尝试exit方法 } } } ~~~