【发布时间】:2017-12-05 18:36:37
【问题描述】:
任何人都可以帮助我在小米和联想设备上接收通知,即使在应用程序被终止后(不再在后台)?
编辑 1
我添加了 GCM 广播接收器。这是代码
在 AndroidManifest.xml 中
<receiver
android:name="com.don.offers.broadcast_receiver.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.google.android.gcm.demo.app" />
</intent-filter>
</receiver>
GcmBroadcastReceiver.java
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ComponentName comp = new ComponentName(context.getPackageName(),
RegistrationIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
它解决了我在 MI 设备上的问题,但在联想设备上却没有。
谢谢
【问题讨论】:
-
嗨。你看到这个post的答案了吗?
-
@AL 是的,我做到了,但这不是我想要的。
标签: android notifications google-cloud-messaging