0

我在应用程序中设置了多个近似警报。我以这种方式设置通知:

private void addProximityAlert(double latitude, double longitude) {

        try{

            LatLonPair latLon;
            for(int i = 0; i < mPositions.size(); i++) {
                latLon = mPositions.get(i);
                Intent intent = new Intent(PROXIMTY_ALERT_INTENT);
                intent.putExtra(ProximityIntentReceiver.EVENT_ID_INTENT_EXTRA, i);
                intent.putExtra(ProximityIntentReceiver.ITEM_NAME,latLon.getItemName());
                intent.putExtra(ProximityIntentReceiver.PLACE_NAME,latLon.getPlaceName());
                PendingIntent proximityIntent = PendingIntent.getBroadcast(this, i, intent, 0);
                locationManager.addProximityAlert(latLon.getLatitude(), latLon.getLongitude(), radius, expiration,  proximityIntent);// alerts set here.
                IntentFilter filter = new IntentFilter(PROXIMTY_ALERT_INTENT);
                registerReceiver(new ProximityIntentReceiver(), filter);            

            }

        }
        catch(Exception ex){
            ex.toString();
        }

      }

所有存储的位置寄存器立即用于接近警报。现在当一个通知被触发并在给定的半径内再次再次触发时发生了什么。我需要帮助我如何删除已经触发的警报,当设备仍在定义半径时不要一次又一次地发出通知。

4

2 回答 2

0

in ProximityIntentReceiver unregister the receiver, so that it won't be called again.

See unregisterReceiver

于 2012-02-27T08:49:43.070 回答
0

问题不在于删除警报。问题是您要多次注册接收器。只做一次。

于 2014-05-23T05:55:23.990 回答