【发布时间】:2017-01-13 05:51:08
【问题描述】:
我有一个扩展应用程序的 A 类。在 A 中,我正在处理未捕获的异常。现在的问题是每当应用程序遇到任何问题时,应用程序都会冻结并在崩溃前出现黑屏
public class A extends Application {
@Override
public void onCreate() {
super.onCreate();
final AppContext context = AppContext.getInstance();
context.setContext(this);
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable e) {
mContext = context.getContext();
e.getCause().getMessage();
AppPreference.getInstance().setCrashReason(e.getMessage());
Intent intent = new Intent ();
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity (intent);
System.exit(1);
}
});
}
我已经搜索了很多,但都是徒劳的。提前谢谢。
【问题讨论】:
标签: android exception-handling