Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to start an activity from an UncaughtExceptionHandler set in application [duplicate]

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?

like image 443
alex2k8 Avatar asked Feb 08 '10 14:02

alex2k8


3 Answers

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.

like image 169
Dave Webb Avatar answered Sep 21 '22 18:09

Dave Webb


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.

like image 28
Mark B Avatar answered Sep 22 '22 18:09

Mark B


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.

like image 29
peter Avatar answered Sep 21 '22 18:09

peter