public class MyApplication extends Application implements Thread.UncaughtExceptionHandler{
@Override
public void onCreate() {
//设置Thread Exception Handler
Thread.setDefaultUncaughtExceptionHandler(this);
}
/**
* 异常重启 - HomeActivity里面做了fragment处理
* @param thread
* @param throwable
*/
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
Log.e("MyApplication", "uncaughtException()" + throwable.getMessage());
System.exit(0);
Intent intent = new Intent(this, SplashActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
就这样色么?你个扑街....
待续....官方解析....
网友评论