public class MyApplication extends Application implements
Thread.UncaughtExceptionHandler {
@Override
public void onCreate() {
super.onCreate();
//设置Thread Exception Handler
Thread.setDefaultUncaughtExceptionHandler(this);
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
System.out.println("uncaughtException");
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
System.exit(0);
}}
最后需要在Manifest中配置Application的标签android:name=