如果接收器和过滤器没有在清单中设置,为什么Broadcastreceiver不会收到意图?
工作1:
locationNotific = new Intent(PROXIMITY_STRING);
lPendingIntent = PendingIntent.getBroadcast(this, 0, locationNotific, PendingIntent.FLAG_CANCEL_CURRENT);
filter = new IntentFilter(PROXIMITY_STRING);
contextOnCreate.registerReceiver(new ProximityIntentReceiver(), filter);
lm.addProximityAlert(LatitudeE6ForPeox1,LongitudeE6ForPeox1,POINT_RADIUS,-1,lPendingIntent);
在清单1中:
<receiver android:name=".ProximityIntentReceiver">
<intent-filter>
<action android:name="SendProximityIntent">
</action>
</intent-filter>
</receiver>
工作2:
filter = new IntentFilter(PROXIMITY_STRING);
contextOnCreate.registerReceiver(new ProximityIntentReceiver(), filter);
sendBroadcast(locationNotific);//working becouse of that (dosent work just with proximity)
Dosent Working:
identif=Long.toString(id);
locationNotific = new Intent(PROXIMITY_STRING + identif);
lPendingIntent = PendingIntent.getBroadcast(this, 0, locationNotific, PendingIntent.FLAG_CANCEL_CURRENT);
filter = new IntentFilter(PROXIMITY_STRING + identif);
contextOnCreate.registerReceiver(new ProximityIntentReceiver(), filter);
lm.addProximityAlert(LatitudeE6ForPeox1,LongitudeE6ForPeox1,POINT_RADIUS,-1,lPendingIntent);