【发布时间】:2018-04-11 08:58:41
【问题描述】:
以下代码引用自google支持GCM,
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.gcm" />
</intent-filter>
</receiver>
<service
android:name="com.example.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
查询 1. 根据 google 文档,Background execution limits 对 Android Oreo 的上述内容有何影响?或者它会按预期工作而无需更改任何代码?
另外,正如谷歌在下面建议的那样,
如果您在应用开发中以 Android 8.0(API 级别 26)或更高版本为目标,请使用 Firebase Cloud Messaging (FCM)。否则,使用 JobIntentService 类而不是 IntentService 来处理令牌刷新。
查询 2. 基于上述陈述,以下方法是否正确?
@Override
public void onTokenRefresh() {
if (Build.VERSION.SDK_INT >= 26) {
//start JobIntentService
} else {
// start intent service
}
如果是,那么 enqueueWork 的调用者是谁?
注意:由于某些限制,无法迁移到 FCM。
【问题讨论】:
标签: android broadcastreceiver android-8.0-oreo android-8.1-oreo