Tuesday, 6 October 2015

How to get android application crashing into your email id


package com.sanjay.android;
import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Logger;
import com.google.android.gms.analytics.Tracker;

import android.app.Application;
import android.content.Context;

@ReportsCrashes(mailTo = "sanjay01feb@gmail.com",
customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT },                
mode = ReportingInteractionMode.TOAST,
resToastText =android.R.string.VideoView_error_text_unknown )

public class MyApplication extends  Application {

@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
ACRA.init(this);
}
public synchronized  Tracker getTracker() {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
       // analytics.setLocalDispatchPeriod(15);
        Tracker t = analytics.newTracker(getResources().getString(R.string.GA_TRACKER_ID));
//        t.enableAdvertisingIdCollection(true);
    return t;
}
}


Note - download acra-4.6.1.jar and add as library in your android project .






No comments:

Post a Comment