程序异常后自动
来源:互联网 发布:js实现select查询 编辑:程序博客网 时间:2024/04/30 04:14
public class DemoApplication extends Application implements Thread.UncaughtExceptionHandler{private PendingIntent pendingIntent;@Overridepublic void onCreate() {super.onCreate();Thread.setDefaultUncaughtExceptionHandler(this);}@Overridepublic void uncaughtException(Thread thread, Throwable ex) { Intent intent = new Intent(this, MainActivity.class); pendingIntent= PendingIntent.getActivity(getApplicationContext(), -1, intent, (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, 0 , pendingIntent); System.exit(0);
}
程序发生运行时异常时,这个Application会自动捕捉异常,并重启启动app,亲测,ok
1 0
- 程序异常后自动
- 让程序异常退出后自动重启
- 让程序异常退出后自动重启
- 利用SetUnhandledExceptionFilter机制实现程序异常后自动重启
- vs2010 程序出错异常后,自动生成dmp文件
- Linux-- 简单的程序守护脚本,程序异常退出后自动重启
- 开机后自动启动程序
- 程序异常后通过邮件发送
- 关于异常捕获后程序的去向
- wampServer安装后程序异常的解决办法
- C++程序抛出异常后执行顺序
- 程序异常自动生成DMP文件
- -------------------MC1000 下冷启动后自动安装程序-------------------------------
- 程序安装完成后自动运行
- kde 登录后自动运行程序
- 让某个程序开机后自动运行
- django启动后自动调用程序?
- linux下实现进程异常退出后自动重启
- List列表中根据某一个字段,进行去重!
- Memcached, Redis, MongoDB区别
- DEBUG: 此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态。
- 【已解决】You need to use a Theme.AppCompat theme (or descendant) with this activity
- 游戏里C++,JAVA,quick交互
- 程序异常后自动
- Android源码编译
- 9. 桥梁设计模式
- 优秀开源项目的svn地址
- MYSQL知识点:any、some、all 关键字的用法
- 在论坛中出现的比较难的sql问题:36(动态行转列 解析json格式字符串)
- 每个Java程序员需要了解的8个Java开发工具
- 面试题45:和为s的两个数字VS和为s的连续正数序列
- xctool及一些相关的资料