Android UncaughtExceptionHandler
来源:互联网 发布:今日头条济南数据分析 编辑:程序博客网 时间:2024/05/16 02:06
public class BaseApplication extends Application implementsUncaughtExceptionHandler {private static Context context;private PendingIntent restartIntent;@Overridepublic void onCreate() {// TODO Auto-generated method stubsuper.onCreate();BaseApplication.context = getApplicationContext();Thread.setDefaultUncaughtExceptionHandler(this);init();}private void init() {Intent intent = new Intent(getApplicationContext(), ExceptionActivity.class);restartIntent = PendingIntent.getActivity(getApplicationContext(), 0,intent, Intent.FLAG_ACTIVITY_NEW_TASK);}public static Context getContext() {return context;}public static void startActivity(Class<?> activity) {Intent intent = new Intent(context, activity);intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(intent);}@Overridepublic void uncaughtException(Thread thread, Throwable ex) {// TODO Auto-generated method stubSystem.out.println("uncaughtException");AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500,restartIntent); // 0.5钟后重启应用的指定ActivitySystem.exit(2);//结束当前遇到线程出错的应用。}}
0 0
- Android UncaughtExceptionHandler
- Android UncaughtExceptionHandler
- Android Thread.UncaughtExceptionHandler捕获
- Android Thread.UncaughtExceptionHandler捕获
- Android Thread.UncaughtExceptionHandler捕获 .
- Android UncaughtExceptionHandler,捕获错误
- Android Thread.UncaughtExceptionHandler捕获
- Android Thread.UncaughtExceptionHandler捕获
- android 捕获 UncaughtExceptionHandler
- Android UncaughtExceptionHandler捕获Crash
- UncaughtExceptionHandler
- UncaughtExceptionHandler
- UncaughtExceptionHandler
- Android UncaughtExceptionHandler捕获崩溃异常
- android UncaughtExceptionHandler全局异常处理
- Android 捕获错误日志 UncaughtExceptionHandler
- 【Android开发】UncaughtExceptionHandler接口详解
- Android实现崩溃统计(UncaughtExceptionHandler)
- Thunder Mountain
- java面向对象学习01
- *** ERROR L107: ADDRESS SPACE OVERFLOW
- nyoj291 单个欧拉函数值
- 聊聊中国的操作系统
- Android UncaughtExceptionHandler
- 【翻译】“PE文件格式”1.9版 完整译文(附注释)
- 黑马程序员 java基础24天 网络编程学习总结
- jsp传中文参数
- APPWeb+PHP5+SQLite3在S3C6410上移植之一
- 关于TableViewCell复用造成的Cell中不该显示的地方显示
- nyoj152 BigInt结构体
- APPWeb+PHP5+SQLite3在S3C6410上移植之二
- Art of Multiprocessor Programming 答案 ch14