0

ユーザー/デバイスが事前定義された関心のあるポイントの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);

    }
}
4

1 に答える 1

1

それが機能するようになりました...これを行うための最良の方法であるかどうかはわかりませんが、とにかく...

解決策:http ://www.gauntface.co.uk/pages/blog/2010/01/04/proximity-alerts-in-android/

私の解決策:broadcastReceiverは複数のブロードキャストをキャッチできますか?

于 2011-02-10T00:42:15.180 に答える