Here is my code snippet.I don't know why its not working. When I open application on my android (S3) phone. No information is displaying in real time view.
这是我的代码片段。我不知道为什么它不起作用。当我在我的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();
}
Manifest also include required permissions.
清单还包括所需的权限。
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
1 个解决方案
#1
0
Have you tried giving a look to the logs while using the emulator. Might be helpful. Otherwise might give below solution a try.
您是否尝试在使用模拟器时查看日志。可能会有所帮助。否则可能会尝试下面的解决方案。
I too had some problems with the instation of the GATracker. The latest library includes EasyTracker
which saves you from the overhead.
我也对GATracker的设置有一些问题。最新的库包括EasyTracker,可以节省您的开销。
-- Add res/values/analytics.xml
file which contains the analytics profile
config details.
- 添加包含分析配置文件配置详细信息的res / values / analytics.xml文件。
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-XXXX-Y</string>
<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>
<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>
-- Set context for EasyTracker
in your activity using the following
- 使用以下内容在您的活动中设置EasyTracker的上下文
EasyTracker.getInstance().setContext(this);
-- Now you cane make a call to EasyTracker
- 现在你可以打电话给EasyTracker
@Override
public void onStart() {
super.onStart();
... // The rest of your onStart() code.
EasyTracker.getInstance().activityStart(this); // Add this method.
}
@Override
public void onStop() {
super.onStop();
... // The rest of your onStop() code.
EasyTracker.getInstance().activityStop(this); // Add this method.
}
-- Other event calls can be made like,
- 其他事件调用可以像,
EasyTracker.getInstance().sendEvent(String category, String action, String label, long value);
Hope this helps. A more detailed documentation can be found here
希望这可以帮助。可以在此处找到更详细的文档
#1
0
Have you tried giving a look to the logs while using the emulator. Might be helpful. Otherwise might give below solution a try.
您是否尝试在使用模拟器时查看日志。可能会有所帮助。否则可能会尝试下面的解决方案。
I too had some problems with the instation of the GATracker. The latest library includes EasyTracker
which saves you from the overhead.
我也对GATracker的设置有一些问题。最新的库包括EasyTracker,可以节省您的开销。
-- Add res/values/analytics.xml
file which contains the analytics profile
config details.
- 添加包含分析配置文件配置详细信息的res / values / analytics.xml文件。
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-XXXX-Y</string>
<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>
<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>
-- Set context for EasyTracker
in your activity using the following
- 使用以下内容在您的活动中设置EasyTracker的上下文
EasyTracker.getInstance().setContext(this);
-- Now you cane make a call to EasyTracker
- 现在你可以打电话给EasyTracker
@Override
public void onStart() {
super.onStart();
... // The rest of your onStart() code.
EasyTracker.getInstance().activityStart(this); // Add this method.
}
@Override
public void onStop() {
super.onStop();
... // The rest of your onStop() code.
EasyTracker.getInstance().activityStop(this); // Add this method.
}
-- Other event calls can be made like,
- 其他事件调用可以像,
EasyTracker.getInstance().sendEvent(String category, String action, String label, long value);
Hope this helps. A more detailed documentation can be found here
希望这可以帮助。可以在此处找到更详细的文档