Google Analytics v4 claims to be capable of reporting uncaught exceptions。但是,evidence suggests that it cannot。因此,我的问题是:Google Analytics v4可以处理未捕获的异常吗?如果是这样,有人可以提供一个最小的例子吗?
答案 0 :(得分:0)
我发现了这个并在我的项目中使用它:
private void uncaughtExceptionHandler() {
Thread.UncaughtExceptionHandler myHandler = new ExceptionReporter(easyTracker,
GAServiceManager.getInstance(),
Thread.getDefaultUncaughtExceptionHandler(), this);
// Make myHandler the new default uncaught exception handler.
Thread.setDefaultUncaughtExceptionHandler(myHandler);
}
你必须在onCreate中调用这个方法:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
easyTracker = EasyTracker.getInstance(this);
uncaughtExceptionHandler();
//
}