【发布时间】:2015-04-14 04:27:54
【问题描述】:
我搜索了很多然后才知道如何在您的应用中实施 Google 分析策略,请参阅下面的答案,这里我为初学者解释了最简单的方法。
【问题讨论】:
标签: android google-analytics privacy policy
我搜索了很多然后才知道如何在您的应用中实施 Google 分析策略,请参阅下面的答案,这里我为初学者解释了最简单的方法。
【问题讨论】:
标签: android google-analytics privacy policy
使用 Google 分析策略编译您的应用程序有很多不同的方法,以下是我分享知识的方式,如果您觉得这有用,请投票。
首先将以下几行添加到您的 Play 商店应用说明中
为了使“您的应用名称”更好,此应用使用 Google Analytics 匿名跟踪应用程序内的使用数据。
String.xml
<string name="off">Off</string>
<string name="send_usage_statistics">Send anonymous usage statistics</string>
<string name="send_usage_summary">To make <Your App Name> better,This application uses Google Analytics to anonymously track usage data within the application.</string>
在您的偏好中 - xml (prefrence.xml)
<CheckBoxPreference android:key="send_usage"
android:defaultValue="true"
android:title="@string/send_usage_statistics"
android:summaryOn="@string/send_usage_summary"
android:summaryOff="@string/off"/>
在您的 PrefrenceActivity.java 中
private void initGoogleAnalytic(CheckBoxPreference checkBoxPreference){
checkBoxPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
CheckBoxPreference swp = (CheckBoxPreference)preference;
boolean isChecked=swp.isChecked();
GoogleAnalytics.getInstance(getApplicationContext()).setAppOptOut(isChecked);
// boolean isd=GoogleAnalytics.getInstance(getApplicationContext()).getAppOptOut();
return false;
}
});
}
最后将上述方法调用为
initGoogleAnalytic((CheckBoxPreference) findPreference("send_usage"));
【讨论】: