这是我的代码片段。我不知道为什么它不起作用。当我在我的 android (S3) 手机上打开应用程序时。实时视图中没有显示任何信息。
public class MainActivity extends Activity {
GoogleAnalyticsTracker analyticsTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
analyticsTracker = GoogleAnalyticsTracker.getInstance();
analyticsTracker.startNewSession("UA-XXXXXXX-X", 5, this);
analyticsTracker.trackPageView("/HomeScreen");
setContentView(R.layout.activity_main);
;
}
public void one(View view) {
analyticsTracker.trackEvent("OneCategory", // Category
"OneAction", // Action
"One", // Label
77); // Value
analyticsTracker.trackPageView("/HomeScreen");
}
public void two(View view) {
analyticsTracker.trackEvent("TwoCategory", // Category
"TwoAction", // Action
"Two", // Label
77); // Value
analyticsTracker.trackPageView("/HomeScreen");
}
public void three(View view) {
analyticsTracker.trackEvent("ThreeCategory", // Category
"ThreeAction", // Action
"Three", // Label
77); // Value
analyticsTracker.trackPageView("/HomeScreen");
}
public void dispatch(View view) {
analyticsTracker.dispatch();
}
@Override
protected void onDestroy() {
analyticsTracker.stopSession();
super.onDestroy();
}
清单还包括所需的权限。
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>