问题
I have implemented in my project the exception reporting feature of Google Analytics (Android SDK) described here :
https://developers.google.com/analytics/devguides/collection/android/v2/exceptions?hl=fr
I would like to use ExceptionParser as explained at the bottom of the page but I don't understand what they mean by :
// Where myParser represents your implementation of ExceptionParser.
ExceptionParser parser = new myParser(context);
What should I write in the myParser class ?? Why this class is not part of the Google Analytics SDK ?
Thanks !
回答1:
They say 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 may create a new class that implements that interface and overrides getDescription()
.
Something like this:
public class MyParser implements ExceptionParser{
@Override
public String getDescription(String threadName, Throwable t){
return threadName+", "+t.get.....
}
}
(Note that I'm not sure that return type of getDescription()
is String
. You should put the appropriate return type)
回答2:
Thanks !
I used Andy Res answer. My full getDescription method is :
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;
}
来源:https://stackoverflow.com/questions/17215904/google-analytics-android-sdk-exceptions-report-myparser-represents-your-imp