ExceptionReporter

  • ExceptionReporter catches uncaught exceptions and reports them to Google Analytics.

  • The message reported is determined by an ExceptionParser, which can be customized.

  • All exceptions reported by this class are considered fatal.

public classExceptionReporter extendsObject
implementsThread.UncaughtExceptionHandler

Used to catch any uncaught exceptions and report them to Google Analytics. This class will call GoogleAnalytics.dispatchLocalHits() after calling Tracker.send(Map).

The exact message reported is determined by theExceptionParser set via the setExceptionParser(ExceptionParser) method. SeeStandardExceptionParser for an example of an implementation ofExceptionParser.

All exceptions reported via this class will be reported as fatal exceptions.

Usage:

 UncaughtExceptionHandler myHandler = new ExceptionReporter(   myTracker,                                     // Currently used Tracker.   Thread.getDefaultUncaughtExceptionHandler(),   // Current default uncaught exception handler.   context);                                      // Context of the application. // Make myHandler the new default uncaught exception handler. Thread.setDefaultUncaughtExceptionHandler(myHandler);

Public Constructor Summary

Public Method Summary

ExceptionParser
void
void

Inherited Method Summary

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()
From interface java.lang.Thread.UncaughtExceptionHandler
abstract void
uncaughtException(Thread arg0,Throwable arg1)

Public Constructors

publicExceptionReporter(Tracker tracker,Thread.UncaughtExceptionHandler originalHandler,Context context)

Parameters
trackeran activeTracker instance. Should not be null.
originalHandlerthe currentDefaultUncaughtExceptionHandler.
contextthe current app context. Should not be null.

Public Methods

publicExceptionParsergetExceptionParser()

public voidsetExceptionParser(ExceptionParser exceptionParser)

public voiduncaughtException(Thread t,Throwable e)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.