0

신청서에 여러 개의 대략적인 알림을 설정했습니다. 나는이 방법으로 알림을 설정 : 한 번에 근접 경보에 대한pendingIntent가 주어진 반지름에서 다시 시작됩니다.

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(); 
     } 

     } 

모든 저장된 위치 레지스터는 하나의 통지가 불이며, 주어진 반경에 또 다시 발사 지킬 때 거기에 무슨 일이 있었는지 부탁해. 내가 한 번 해고 한 Alert를 제거하는 방법이 기기가 아직 반경을 정의하고있을 때 다시 알려주지 않도록 도와야합니다.

답변

0

ProximityIntentReceiver에서 수신기를 등록 취소하면 다시 호출되지 않습니다.

이 문제는 알림이 제거되지 않습니다 unregisterReceiver

+0

만약 내가 unregisterReceiver를 사용한다면 나의 모든 의도는 아직 발화되지 않은 것을 제거 할 것입니다. –

0

를 참조하십시오. 문제는 수신기를 여러 번 등록하는 것입니다. 한 번만하십시오.

관련 문제