当我们在Android中实施GCM(Google云消息传递)时,我们必须在每个应用程序中提供接收器。根据我的知识,如果你有多个应用程序有自己的接收器映射为共同的行动"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>
答案 0 :(得分:1)
在GCM广播接收器的intent过滤器的category
中指定包名称时,将com.google.android.c2dm.intent.RECEIVE
操作的范围缩小到应该传递GCM消息的特定应用程序的范围到。