Reputation: 437
I am new to Android and developing a background service that would track whether the person is inside or outside of certain radius of an area (fixed lat/long coordinates).
Battery is critical and I don't need actual location (coarse location). It is fine if the event is delivered few minutes after the actual entry/exit as I need just one notification for entry and one for exit
I don't want alarm manager to trigger every 10 minutes to check current location as this would drain battery. Is there a way to achieve this with minimal battery drain and preferably without having the user to turn on GPS (consumes battery)?
Upvotes: 1
Views: 866
Reputation: 20346
It is called Geofencing. There is good article on Developers site. But it requires GPS (FINE_LOCATION).
Another solution: implement own Geofence-like "framework", but using network data (COARSE_LOCATION), not GPS. Yes, it requires periodical polling of location. A way to decrease battery drain is to poll less frequently. Also you can use location updates listener with a low priority.
Upvotes: 0
Reputation: 4361
Look like you can build a GeoFence and send notification on GeoFence transition. Please see this documentation: https://developer.android.com/training/location/geofencing.html
Upvotes: 1