Tuesday, 15 May 2012

java - Android Intercept Unhandled Exceptions -


So I want to prevent unconfirmed exceptions and I am doing this:

  thread .setDefaultUncaughtExceptionHandler (new thread). UncategorizedAppsHandler () {@Override to send public zero uncaughtException (Thread T, Throws E) {// LOGS System.exit (2);}}) to my custom code;  

Anyway, can I execute my custom code and then handle it with exceptions and resume it normally? system.exit is not working as trusted because I believe that I'm having some hanging problems.

You must first obtain the default handler. Then send the handler to the blocker and the error System.exit ... is a bad idea.

Then you make a custom exception handler as you did:

  The public class implements the CustomExceptionHandler thread. UncaughtExceptionHandler {Private Final Thread .UncaughtExceptionHandler DefaultUEH; Public CustomExceptionHandler (Thread.UncaughtExceptionHandler defaultUEH) {this.defaultUEH = defaultUEH; } @ Override public empty trace string (ex); String StackTrace = Log .getStackTraceString (ex); String Time = New Date (SystemCurrentTime) ToString (); String message = ex.getMessage (); // Send Logs ... Default: H. Enqueued Expression (thread, pre); }}  

So basically set the default exception handler (in the best use custom application category to drop it in all parts) if not already set (Not required in application):

  thread. Unwanted Exhibit Handler DefaultUH = Thread.GetDigitalAnrollExceptionHandler (); If (Default (EEH example customExceptionHandler)) {Thread.setDefaultUncaughtExceptionHandler (New CustomExceptionHandler (defaultUEH)); }  

I have written it (delete the BuildConfig.DEBUG check) to start the email client directly. If no email client is installed, then you have to catch the ActivityNotFoundException


No comments:

Post a Comment