Reputation: 38
I am making an application which notifies user when he is near certain locations,it may need various geofences to be activated at same time.
since android's geofencing API's were recently updated with new Play Services and update mention to improve battery consumption
Is it better to use multiple geofences simultaniously to get notifications or should i send user's location to server on periodic basis and decide there whether to notify user or not
Do multiple geofences consume more memory than retrieving location and sending to server
NOTE:number of geofences may be more than 100 so i can use solution posted here in that case
Upvotes: 1
Views: 1073
Reputation: 11
I've donne something similar but I used BLE, my aproach was to create a RESTful API in the backend where I got all the geofences and tokens and consume it with Retrofit2 so in order to check if the user was near just did a quick operation (cause sometimes you don´t have beacons) :
for (int i = 0; i < latitud.length; i++) {
dest.setLatitude(latitud[i]);
dest.setLongitude(longitud[i]);
dist = me.distanceTo(dest);
if (dist <= 200) {
Toast.makeText(this, "Near of " + lugares[i]+ " get a reward!", Toast.LENGTH_LONG).show();
}
}
I leave the example here, and some other in my git account. Regards and hope it helps. https://github.com/AlbertoMobileApps/SimpleLocationExample
Upvotes: 1