I believe you have a database storing all geofence info. When adding a new geofence, you can first record it into the database. And then retrieve all geofences in the databse, and add them all to the locationClient as new geofences.
Add new geofence(s) every time the sever pushes
-
28-08-2022 - |
Question
Initially, I have added 5 geofences to LocationClient.
After some time I need to add new geofences, say 3.
What shall I do to have all 8 geofences active.
Shall I remove initial 5 geofences and add all 8 at once. OR Shall I add 3 new geofences as below.
Intent geofenceIntent = new Intent(this, GeofenceIntentService.class);
PendingIntent pIntent = PendingIntent.getService(this,
0,
geofenceIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
locationClient.addGeofences(geofences, pIntent, LocationIntentService.this);
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow