我有4个fragments
和2 activities
我已经实现了以下代码:
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
//...
private Tracker mTracker;
//...
AnalyticsApplication application = (AnalyticsApplication) getActivity().getApplication();
mTracker = application.getDefaultTracker();
//...
@Override
public void onResume() {
Log.i(TAG, ""+TAG); //TAG represents the name of the current activity/fragment
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
super.onResume();
}
我想要做的是跟踪每个活动和片段的使用情况,并实时获取当前活跃用户并在我的Google Analytics控制台中接收信息,但我没有设法接收任何数据
P.S。到目前为止,我只测试了我的设备
答案 0 :(得分:0)
通过添加以下行来实现:
mTracker.setScreenName("Screen name: " + TAG);
最终结果
@Override
public void onResume() {
Log.i(TAG, ""+TAG); //TAG represents the name of the current activity/fragment
mTracker.setScreenName("Screen name: " + TAG); //added line
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
super.onResume();
}