当我们在 android 中实现 GCM(谷歌云消息传递)时,我们必须在每个应用程序中提供我们的接收器。据我所知,如果您有多个应用程序有自己的接收器映射以执行常见操作“com.google.android.c2dm.intent.RECEIVE”
。每个应用程序中的接收器都应该调用但不调用,我想知道 android 如何识别应该调用哪个应用程序的接收器?
<receiver
android:name=".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>
最佳答案
当您在 GCM 广播接收器的 intent 过滤器的 category
中指定您的包名称时,您缩小了 com.google.android.c2dm.intent.RECEIVE 的范围
对 GCM 消息应传递到的特定应用程序的操作。
关于android - 跨应用程序在 GCM 中执行相同操作的多个接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22007317/