开发者

addProximityAlert fired only with the last location

开发者 https://www.devze.com 2023-03-19 15:54 出处:网络
I\'m using next function to set proximityAlerts: public void addProximityAlerts(double latitude, double longitude, double radius)

I'm using next function to set proximityAlerts:

public void addProximityAlerts(double latitude, double longitude, double radius) 
    {
        try{
            //Prepare proximity Intent
            proximityIntent = new Intent(activityContext.getString(R.string.intent_message_location_fetched));
            proximityPendingIntent = PendingIntent.getBroadcast(activityContext, 0, proximityIntent, PendingIntent.FLAG_CANCEL_CURRENT);

            locationManager.addProximityAlert(latitude, longitude, (float) radius, -1, proximityPendingIntent);
        }
        catch (Exception开发者_如何学Go e) {
            Log.d("ERROR", e.toString());
            SendHandle(LOCATION_ADDING_ALERTS_FAILED);


}
}

And call this:

location.addProximityAlerts(33.3333, 33.3333, 1000);
location.addProximityAlerts(12, 12, 5000);
location.addProximityAlerts(42, 42, 5000);

But Intent fired only when I'm around 42, 42 - the last used location. What's wrong? Shouldn't alerts work with all given points?


Action must be unique! Thank this

Now I'm creating receiver in the addProximityAlerts finction using

getString(R.string.intent_message_location_fetched)+latitude+longitude

as unique action

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号