自过去一周以来,它没有显示实时数据。它以前工作过。你们这几天面临同样的问题,还是仅仅是我? 这是代码
public class MyApplicationClass extends Application {
private static final String PROPERTY_ID = "UA-XXXXXXXX-X";
public MyApplicationClass(){
super();
}
public enum TrackerName {
APP_TRACKER,
GLOBAL_TRACKER,
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
GoogleAnalytics.getInstance(this).getLogger()
.setLogLevel(Logger.LogLevel.VERBOSE);
Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID)
: analytics.newTracker(R.xml.global_tracker);
}
return mTrackers.get(trackerId);
}
}
我通过调用这个静态方法发送数据
public class MyAnalyticsTracker {
public static void tracker(String screenName, String category, String action, String label, Activity activity) {
GoogleAnalytics.getInstance(activity.getBaseContext()).dispatchLocalHits();
GoogleAnalytics.getInstance(activity.getBaseContext()).reportActivityStart(activity);
GoogleAnalytics.getInstance(activity.getBaseContext()).setLocalDispatchPeriod(3);
GoogleAnalytics.getInstance(activity.getBaseContext()).setAppOptOut(false);
Tracker t = ((MyApplicationClass) activity.getApplication()).getTracker(
MyApplicationClass.TrackerName.APP_TRACKER);
t.setScreenName(screenName);
t.enableAutoActivityTracking(true);
t.setSampleRate(50.0d);
t.setAnonymizeIp(true);
t.enableAdvertisingIdCollection(true);
t.send(new HitBuilders.AppViewBuilder().build());
t.send(new HitBuilders.EventBuilder()
.setCategory(category)
.setAction(action)
.setLabel(label)
.build());
}
}
请帮忙。提前谢谢!