企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
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方法 } } } ~~~