I want all exceptions that may occur in the application while the user is running, send it to the Andoid Developer Console. Suppose that the exception information is sendFeedback() using the sendFeedback() method. And here the question arises: where should I place this method sendFeedback() , given that this method will be used throughout the application? And how to use it? I have two suggestions:

  1. in the Application class (and then in every catch -e of each try-catch call this method)
  2. in the class that implements the java.lang.Thread.UncaughtExceptionHandler interface (and then on each Thread.setDefaultUncaughtExceptionHandler(...) call Thread.setDefaultUncaughtExceptionHandler(...) )

How correct is it? Or are both options bad and better done somehow differently?

  • The second option is normal. You can see here (at the end of the question) a specific code for catching errors: ru.stackoverflow.com/q/418978/17609 - JuriySPb
  • if there is a question of implementing my own solution, then I would put it on the application class (but I myself have not tried it that way))) - Georgy Chebotarev

1 answer 1

Why don't you use a ready-made solution, for example https://fabric.io ? It connects to his application, and starts to receive statistics about crashes from all devices. Very handy thing

  • Yes, thanks, I know that there are libraries for error handling, and, in particular, I used acre (ACRA). But I want to do this without third-party libraries. - Ksenia
  • @Ksenia don't you think that just people started writing libraries, because the standard tool does not fit. - Shwarz Andrei
  • Well, in the development of different cases are, sometimes you have to repeat and add your own. - Georgy Chebotaryov