ユーザー/デバイスが事前定義された関心のあるポイントの1つに近づくたびにアラートを表示するアプリを作成しています。
それを行うために私が見つけた唯一の方法(実際、私はそれをそのように機能させました)は、関心のあるすべてのポイントに対して(一意の名前で)保留中のインテントを作成することです。しかし、それはリソースの観点からそれを行うための最良の方法ではないと思います..
複数の個別の意図ではなく、保留中の意図を 1 つだけ使用して、このような機能を実現することは可能ですか?
それを行う他の良い方法はありますか?
前もって感謝します
マイク
private void addProximityAlert(double latitude, double longitude, String poiName) {
Bundle extras = new Bundle();
extras.putString("name", poiName);
Intent intent = new Intent(PROX_ALERT_INTENT+poiName);
intent.putExtras(extras);
PendingIntent proximityIntent = PendingIntent.getBroadcast(MainMenu.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(poiName);
registerReceiver(new ProximityIntentReceiver(), filter);
}
}