如果接收器和过滤器没有在清单中设置,为什么Broadcastreceiver不会收到意图?

时间:2011-12-13 19:35:22

标签: java android android-intent broadcastreceiver proximity

如果接收器和过滤器没有在清单中设置,为什么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);

0 个答案:

没有答案