以前に別のアクティビティで作成した保留中のインテント (ブロードキャスト) を無効にしようとしていますが、機能させることができません。インテントを再作成し(同じエクストラとすべてを使用して)、それをパラメーターとして渡して、pendingIntent をインスタンス化し、pendingIntent をパラメーターとしてロケーション マネージャー removeUpdates メソッドに渡す必要があることを読みました。
言い換えると:
Bundle extra = new Bundle();
extra.putString("name", extras.getString("poiName")); //create same extras
extra.putInt("id", extras.getInt("rowId")); //create same extras
Intent intent = new Intent(PROX_ALERT_INTENT);
intent.putExtra(PROX_ALERT_INTENT, extra); //put same extras in the intent
PendingIntent proximityIntent = PendingIntent.getBroadcast(this.getApplicationContext(),extras.getInt("rowId") , intent, PendingIntent.FLAG_UPDATE_CURRENT); //pass in the intent
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.removeUpdates(proximityIntent); //remove pendingIntent
それはうまくいかなかったので、保留中の意図を作成するために使用されたものと同じではなく、新しいオブジェクトであるという意図に関係している可能性があると考えました。
だから私はそれを作成した直後に pendingIntent を削除しようとしましたが、それはどちらもうまくいきませんでした:
Bundle extras = new Bundle();
extras.putString("name", poiName);
extras.putInt("id", requestCode);
Intent intent = new Intent(PROX_ALERT_INTENT);
intent.putExtra(PROX_ALERT_INTENT, extras);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this.getApplicationContext(), requestCode , intent, PendingIntent.FLAG_CANCEL_CURRENT);
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
);
locationManager.removeUpdates(proximityIntent);
それを手伝ってくれませんか?水曜日以来、盗聴されています...これにバウンディを置くための評判がもっとあればいいのに...
ありがとう
マイク