1

如果清单中没有设置接收器和过滤器,为什么广播接收器没有接收到意图?

工作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)

剂量工作:

    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);
4

0 回答 0