我需要多长时间才能在Android应用中等待Google Analytics的实时数据

时间:2014-11-26 16:17:15

标签: java android google-analytics

以下行是我的Google Analytics v4设置。一切看起来都很正确。应用程序工作正常,但我无法在Google Analytics控制台上看到实时和其他数据。为什么呢?

GoogleAnal.java

public class GoogleAnal extends Application {
    public GoogleAnal() {
        super();
        }
    public enum TrackerName {
        APP_TRACKER, // Tracker used only in this app.
    }

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


    synchronized Tracker getTracker(TrackerName trackerId) {
        if (!mTrackers.containsKey(trackerId)) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            if(trackerId == TrackerName.APP_TRACKER){
                Tracker t = analytics.newTracker(R.xml.app_tracker);
                mTrackers.put(trackerId, t);
            }         
        }
        return mTrackers.get(trackerId);
    }

}

MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
....
....
....
Tracker t = ((GoogleAnal) this.getApplication()).getTracker(TrackerName.APP_TRACKER);
t.setScreenName("Screen1");

}

    @Override
    protected void onStart() {
        super.onStart();
        GoogleAnalytics.getInstance(this).reportActivityStart(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        GoogleAnalytics.getInstance(this).reportActivityStop(this);
    }

0 个答案:

没有答案