在Android应用中实施Google Analytic Android隐私政策和退出政策

时间:2015-02-13 07:15:25

标签: android google-analytics privacy policy

我经常搜索,然后了解如何在您的应用中实施Google分析政策,请参阅下面的答案,我在这里为初学者解释了最简单的方法。

1 个答案:

答案 0 :(得分:1)

使用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>

在您的Prefrence - 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"));