如果这是主线程崩溃,如何从UncaughtExceptionHandler启动活动? [英] How to start activity from UncaughtExceptionHandler if this is main thread crashed?

查看:268
本文介绍了如果这是主线程崩溃,如何从UncaughtExceptionHandler启动活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果检测到未处理的异常,我正在尝试启动错误报告活动。问题是从主线程抛出的异常。如果主线程崩溃,有没有办法开始一个活动?

I am trying to start an error-reporting activty if unhandled exception detected. The problem is with exceptions thrown from main thread. Is there any way to start an activity if main thread crashed?

推荐答案

我所看到的方法用于捕获 UncaughtExcpetionHandler 将崩溃数据写入文件,然后根据崩溃数据文件的存在重新启动应用程序,然后启动错误处理活动

The approach I've seen used for error catching in an UncaughtExcpetionHandler is to write the crash data out to file and then start the error handling Activity when the application is restarted based on the existence of the crash data file.

根据您想要的活动所做的操作,这可能适用于您。

Depending on what you want your Activity to do, this might work for you.

这篇关于如果这是主线程崩溃,如何从UncaughtExceptionHandler启动活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆