要对非 Google Play 设备上运行的应用启用后台调度,请在配置文件 ApplicationManifest.xml 中添加代码,完成以下操作:
获取 WAKE_LOCK 权限。
注册 AnalyticsReceiver。
注册 AnalyticsService。
具体代码:
<!-- Optional permission for reliable local dispatching on non-Google Play devices -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Enable background dispatching to improve delivery on non-Google Play devices -->
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false" />
<!-- Enable Google Play Store Campaign reports -->
<receiver
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:enabled="true" />