Android: the usual way to stop and register a fatal error

As usual, Android stops my application if it reaches a fatal error.

finish () will not do this because it will not stop any running services or threads. In addition, I would like to inform the user what happened and ask him to send an error log.

As I understand it, Google cannot close my application and open a special crashreport activity or something else to show the user what is happening or send a crash log.

+5
source share
3 answers

I think you should throw an unhandled exception at runtime. In this case, the android will kill your entire process. I also suggest you use ACRA . This library will help you get a crash report (via email, google docs, etc.), and it can show a custom error dialog for the user.

+2
source

You have to check it out. This may be your decision. ACRA

Check out the basic installation guide to get started using the library. ACRA - Basic installation

+1
source

While ACRA is a good solution, if you want to implement your own unhandled exception log, try Thread.setDefaultUncaughtExceptionHandler () . This way you can get any exceptions that are thrown and not caught, and register them the way you like. You need to implement Thread.UncaughtExceptionHandler and pass it to this method.

With Activity, it will look something like this in onCreate ():

getMainLooper().getThread().setUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
+1
source

All Articles