Android Update Geofences
Asked Answered
W

1

5

What's the best way to update geofences in Android? Is it to first remove the old set of Geofences and then add the newly updated list like this:

            LocationServices.GeofencingApi.removeGeofences(
                    mGoogleApiClient,
                    getGeofencePendingIntent()
            ).setResultCallback(this);

            LocationServices.GeofencingApi.addGeofences(
                    mGoogleApiClient,
                    getGeofencingRequest(),
                    getGeofencePendingIntent()
            ).setResultCallback(this); // Result processed in onResult().

Or can I just directly call addGeofences without removing the old ones and have the new one's replace the old?

Wallet answered 13/4, 2015 at 0:3 Comment(0)
P
8

If you read the manual first, you'd notice that addGeofences says that:

If an existing geofence with the same request ID is already registered, the old geofence is replaced by the new one, and the new PendingIntent is used to generate intents for alerts.

Psalms answered 13/4, 2015 at 7:51 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.