How to start activity from UncaughtExceptionHandler if this is main thread crashed?

喜你入骨 提交于 2019-12-05 00:26:29

问题


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?


回答1:


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.




回答2:


I think this is the wrong way to go about it. What you need to do is make sure you catch those exceptions, and pop up an error-reporting activity when you catch them.




回答3:


You can add attribute android:process=":report_process" to the <activity> element which refers to your bug report activity in AndroidManifest.xml.

By default, activities belong to the same appliction would run in the same process identified by your package name. By setting android:process attribute, you can override this. android:process starting with : refers to a private identifier within your package, so that you can start the activity in a new process without conflicting other packages' process.



来源:https://stackoverflow.com/questions/6562277/android-how-to-start-an-activity-from-an-uncaughtexceptionhandler-set-in-applic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!