Java 类com.google.android.gms.analytics.ExceptionReporter 实例源码

项目:matrix-android-console    文件:Analytics.java   
/**
 * Initialise Google Analytics immediately so it will catch all sorts of errors prior to EasyTracker onStart. Also makes sensible
 * exception stack traces if you want.
 * @param context App context
 * @param trackerId The tracker ID to use.
 * @return A GoogleAnalytics reference
 */
public static GoogleAnalytics initialiseGoogleAnalytics(Context context, String trackerId, final ExceptionParser callback) {
    mAnalytics = GoogleAnalytics.getInstance(context);
    mAnalytics.setLocalDispatchPeriod(1800);

    mTracker = mAnalytics.newTracker(trackerId);
    mTracker.enableExceptionReporting(true);
    //mTracker.enableAdvertisingIdCollection(true);
    mTracker.enableAutoActivityTracking(true);

    // overwrite the exception parser to be more useful.
    Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
    if (handler != null && handler instanceof ExceptionReporter) { // this handler is the GA one
        ExceptionReporter exceptionReporter = (ExceptionReporter)handler;
        exceptionReporter.setExceptionParser(callback);
        Thread.setDefaultUncaughtExceptionHandler(exceptionReporter);

        Log.d(LOG_TAG, "Analytics active.");
    }
    else {
        Log.e(LOG_TAG, "Cannot set custom exception parser.");
    }

    return mAnalytics;
}
项目:stolpersteine-android    文件:StolpersteineApplication.java   
@Override
public void onCreate() {
    // GoogleAnalytics.getInstance(this).getLogger().setLogLevel(LogLevel.VERBOSE);
    // GoogleAnalytics.getInstance(this).setDryRun(true);

    GoogleAnalytics.getInstance(this).setLocalDispatchPeriod(30);
    tracker = GoogleAnalytics.getInstance(this).newTracker(BuildConfig.APP_GA_ID);
    tracker.setAnonymizeIp(false);

    UncaughtExceptionHandler handler = new ExceptionReporter(tracker, Thread.getDefaultUncaughtExceptionHandler(), this);
    Thread.setDefaultUncaughtExceptionHandler(handler);

    classToViewNameMapping = new HashMap<String, String>();
    classToViewNameMapping.put(MapActivity.class.getName(), "Map");
    classToViewNameMapping.put(CardsActivity.class.getName(), "Cards");
    classToViewNameMapping.put(DescriptionActivity.class.getName(), "Description");

    super.onCreate();
}
项目:anewjkuapp    文件:AnalyticsFlavor.java   
private synchronized Tracker getTracker(TrackerName trackerId) {
    if (!mTrackers.containsKey(trackerId)) {

        GoogleAnalytics analytics = GoogleAnalytics.getInstance(mApp);
        switch (trackerId) {
            case APP_TRACKER:
                Tracker t = analytics.newTracker(Consts.PROPERTY_ID);
                mTrackers.put(trackerId, t);

                Thread.UncaughtExceptionHandler myHandler = new ExceptionReporter(t,
                        Thread.getDefaultUncaughtExceptionHandler(), mApp);
                // Make myHandler the new default uncaught exception handler.
                Thread.setDefaultUncaughtExceptionHandler(myHandler);

                // disable auto activity tracking
                t.enableAutoActivityTracking(false);
                t.enableExceptionReporting(true);

                // try to initialize screen size
                try {
                    WindowManager wm = (WindowManager) mApp.getSystemService(Context.WINDOW_SERVICE);
                    Display display = wm.getDefaultDisplay();

                    Point size = new Point();
                    display.getSize(size);

                    t.setScreenResolution(size.x, size.y);
                } catch (Exception e) {
                    Log.e(TAG, "get sceen size", e);
                }

                break;
        }
    }
    return mTrackers.get(trackerId);
}
项目:android_gisapp    文件:MainApplication.java   
private void setExceptionHandler() {
    ExceptionReporter handler = new ExceptionReporter(getTracker(), Thread.getDefaultUncaughtExceptionHandler(), this);
    StandardExceptionParser exceptionParser =
            new StandardExceptionParser(getApplicationContext(), null) {
                @Override
                public String getDescription(String threadName, Throwable t) {
                    return "{" + threadName + "} " + Log.getStackTraceString(t);
                }
            };

    handler.setExceptionParser(exceptionParser);
    Thread.setDefaultUncaughtExceptionHandler(handler);
}