Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Update Geofences

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?

like image 696
Tom Hammond Avatar asked Mar 16 '23 11:03

Tom Hammond


1 Answers

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.

like image 58
Marian Paździoch Avatar answered Apr 01 '23 19:04

Marian Paździoch