简体   繁体   English

Google Analytics(分析)在Android上无法运作

[英]Google analytics does not work on android

I want to import google analytics on my android application and my codes is 我想在我的Android应用程序上导入Google Analytics(分析),而我的代码是

private GoogleAnalyticsTracker tracker;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo);

    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.startNewSession(getString(R.string.analytics_id), this);
    tracker.trackPageView("/demo");
}

@Override
protected void onDestroy() {
    super.onDestroy();
    tracker.stopSession();
}

but it is not working... where am I doing wrong? 但它不起作用...我在哪里做错了? Thanks... Note: I used tabactivity and each of tab codes like that... 谢谢...注意:我使用了tabactivity和每个这样的tab代码...

I found the answer from this blog. 我从这个博客找到了答案。 Hope it's helpful. 希望对您有所帮助。
http://blog.blundellapps.com/google-analytics-common-problems-and-fixes/ http://blog.blundellapps.com/google-analytics-common-problems-and-fixes/

To Setup 建立

// Add libGoogleAnalytics.jar to your project's /libs directory. //将libGoogleAnalytics.jar添加到项目的/ libs目录中。

// Add the following permissions to your project's AndroidManifest.xml manifest file: //将以下权限添加到项目的AndroidManifest.xml清单文件中:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

EDIT: In order to use Google Analytics, you must be signed in with a registered Google Account email address and password. 编辑:要使用Google Analytics(分析),您必须使用注册的Google帐户电子邮件地址和密码登录。

Create a Google Account here. 在此处创建一个Google帐户 However, just having a Google account does not automatically grant you access to Analytics. 但是,仅拥有Google帐户并不会自动授予您访问Google Analytics(分析)的权限。 First, you must r egister for Google Analytics , a one-time, simple process. 首先,您必须重新注册Google Analytics(分析) ,这是一个一次性的简单过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM