Google Analytics Android SDK / Exceptions report : “myParser represents your implementation of ExceptionParser”

风格不统一 提交于 2019-12-08 13:35:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!