1

を使用してAddProximityAlert()います。しかしBroadcastReceiver、私の現在の場所でのみ動作します。

  private void addProximityAlert() {
       double latitude = Double.parseDouble("23.5918106");
       double longitude = Double.parseDouble("58.2288041");
       Intent intent = new Intent(PROX_ALERT_INTENT);
       PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, 0);

       locationManager.addProximityAlert(
           latitude, // the latitude of the central point of the alert region
           longitude, // the longitude of the central point of the alert region
           POINT_RADIUS, // the radius of the central point of the alert region, in meters
           PROX_ALERT_EXPIRATION, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration 
           proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected
      );

      IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);  
      registerReceiver(new ProximityIntentReceiver(), filter);
      Toast.makeText(getApplicationContext(),"Alert Added",Toast.LENGTH_SHORT).show();
}

この部分は呼び出しには機能しませんBroadcastReceiver:

 IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);  
 registerReceiver(new ProximityIntentReceiver(), filter);
4

0 に答える 0