Google Analytics Report Android SDK / Exceptions: "myParser represents your implementation of ExceptionParser"

I implemented an exception reporting function in the Google Analytics (Android SDK) described in my project:

https://developers.google.com/analytics/devguides/collection/android/v2/exceptions?hl=fr

I would like to use ExceptionParser as described at the bottom of the page, but I don't understand what they mean:

// Where myParser represents your implementation of ExceptionParser. ExceptionParser parser = new myParser(context); 

What should I write in myParser class? Why is this class not part of the Google Analytics SDK?

Thanks!

0
android exception exception-handling google-analytics google-analytics-api
source share
2 answers

It is said that ExceptionParser is an interface and has only 1 method: getDescription(String threadName, Throwable t) .

So, to get the most relevant description of the exception, you can create a new class that implements this interface and overrides getDescription() .

Something like that:

 public class MyParser implements ExceptionParser{ @Override public String getDescription(String threadName, Throwable t){ return threadName+", "+t.get..... } } 

(Note that I'm not sure if the return type of getDescription() is String . You must specify the appropriate return type)

+2
source share

Thanks!

I used the answer of Andy Res. My full getDescription method:

 public String getDescription(String threadName, Throwable t) { // TODO Auto-generated method stub String description = "threadName = " + threadName + "\ngetMessage()= " + t.getMessage() + "\ngetLocalizedMessage()=" + t.getLocalizedMessage() + "\ngetCause()=" + t.getCause() + "\ngetStackTrace()=" + t.getStackTrace(); return description; } 
+1
source share

All Articles