この質問はすでに存在しますが、ソリューションの実装に問題があります。
私はこれらの質問をガイドラインとして使用しています:
受信者を登録する場所:
final String NEAR_YOU_INTENT = "neighborhood.crodgers.example.activities.PROXIMITY_ALERT";
IntentFilter filter = new IntentFilter(NEAR_YOU_INTENT);
registerReceiver(new LocationReceiver(), filter);
近接アラートが追加される場所(注:これはサービスで行われるため、コンテキストグラブ):
LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
final String NEAR_YOU_INTENT = "neighborhood.crodgers.example.activities.PROXIMITY_ALERT";
Context context = getApplication().getApplicationContext();
int requestCode = 12345; //Spaceballs, anyone? anyone?
for (String domain : domainNames)
{
String[] itemNames = itemGetter();
for (String item : itemNames)
{
HashMap<String, String> attributes = getAttributesForItem(domain, item);
Intent intent = new Intent(NEAR_YOU_INTENT);
intent.putExtra(ADDRESS, attributes.get(ADDRESS));
intent.setAction(""+requestCode);
PendingIntent proximity = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
manager.addProximityAlert(Double.parseDouble(attributes.get(LATITUDE)),
Double.parseDouble(attributes.get(LONGITUDE)),
6000f, -1, proximity);
requestCode++;
}
}
元々、(受信者からの通知を使用して)追加された最初の近接アラートの通知を受け取っていました。追加後
intent.setAction(""+requestCode);
私も試しました:
intent.setData(""+ requestCode)
(私はこれが他のいくつかの場所で推奨されているのを見ました)私は通知をまとめて受け取るのをやめました。