未捕获的例外不起作用

时间:2014-08-25 02:04:12

标签: android google-analytics

我的app_tracker.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="TypographyDashes">
    <!-- The apps Analytics Tracking Id -->
    <string name="ga_trackingId">UA-XXXXXXXX-1</string>
    <!-- Percentage of events to include in reports -->
    <string name="ga_sampleFrequency">100.0</string>
    <!-- Enable automatic Activity measurement -->
    <bool name="ga_autoActivityTracking">true</bool>
    <!-- catch and report uncaught exceptions from the app -->
    <bool name="ga_reportUncaughtExceptions">true</bool>
    <!-- How long a session exists before giving up -->
    <integer name="ga_sessionTimeout">-1</integer>
</resources>

global_tracker.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="TypographyDashes">
    <!-- the Local LogLevel for Analytics -->
    <string name="ga_logLevel">verbose</string>
    <!-- how often the dispatcher should fire -->
    <integer name="ga_dispatchPeriod">1</integer>
    <!-- Treat events as test events and don't send to google -->
    <bool name="ga_dryRun">false</bool>
    <!-- The screen names that will appear in reports -->
    <string name=".BaseActivity">Base Activity</string>
</resources>

Application.java

public class Application extends Application {
    private static final String PROPERTY_ID = "UA-XXXXXXXX-1";

    //Logging TAG
    private static final String TAG = "Application";

    HashMap<TrackerName, Tracker> mTrackers = 
        new HashMap<TrackerName, Tracker>();

    public static int GENERAL_TRACKER = 0;

    public enum TrackerName {
        APP_TRACKER, 
        GLOBAL_TRACKER, 
    }

    public Application() {
        super();
    }

    public synchronized Tracker getTracker(TrackerName trackerId) {
        if (!mTrackers.containsKey(trackerId)) {

            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            Tracker t = (trackerId == TrackerName.APP_TRACKER) ? 
                                    analytics.newTracker(R.xml.app_tracker)
                    : (trackerId == TrackerName.GLOBAL_TRACKER) ? 
                                    analytics.newTracker(PROPERTY_ID)
                    : analytics.newTracker(R.xml.global_tracker);
            mTrackers.put(trackerId, t);

        }
        return mTrackers.get(trackerId);
    }
}

活动

public class SplashActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Application app= (Application) getApplication();
        Tracker myTracker=app.getTracker(Application.TrackerName.APP_TRACKER);
        myTracker.enableAutoActivityTracking(true);
        myTracker.enableExceptionReporting(true); //add this line
        GoogleAnalytics.getInstance(this).enableAutoActivityReports(app);
        super.onCreate(savedInstanceState);
        if(true){
            new Integer("asdfas");
        }
}

我正在尝试向谷歌分析报告所有未被捕获的例外情况,但它无效。任何人都知道为什么我的未被捕获的例外没有被发送到谷歌分析?

提前感谢。

1 个答案:

答案 0 :(得分:1)

异常报告可能需要一两天才能显示在分析控制台中。