0

I have an app which will take some (internet) action every time the user approaches any one of a set of locations (for example, let's say it notifies a server whenever I am near a Starbucks shop, so my coffee habits can be analysed).

What's the most battery-efficient (yet reliable and relatively accurate) way of causing the phone to do something whenever it's at a certain location? I don't need perfect location accuracy - within 50m or so is fine.

Currently, I set a ProximityAlert for each location with a 100m radius, and have it raise an Intent, which is then served by a Service which runs in the background. The service also includes an Alarm which causes a download every three hours or so.

The Service itself doesn't appear to drain any significant amount of battery - the battery is all drained by "Android OS". According to the Android 4.1.2 Battery monitor, Android OS is using 3x as much CPU as a phone without my app, and has "stay awake" on for most of the time.

Would changing it to an IntentService make a difference?

Would reducing (or increasing) the radius of the alert make a difference?

Would converting it to a Geofence (https://developer.android.com/training/location/geofencing.html) make much difference?

Can I set it to use a cheaper location service unless it thinks it's close to one of the locations (or will it do that automatically?)

Richard Russell
  • 1,105
  • 1
  • 10
  • 19
  • maybe you should try [Geofencing APIs](http://developer.android.com/google/play-services/location.html) - [references](http://developer.android.com/reference/com/google/android/gms/location/Geofence.html) – Selvin Jun 18 '13 at 10:16
  • Thanks - added this to the question – Richard Russell Jun 18 '13 at 14:46

3 Answers3

2

I have never worked with the LocationManagers proximity alert functions, so I do not really know how much they drain the battery, but as far I know the new Geofence services (https://developer.android.com/training/location/geofencing.html) were specially designed in a battery-friendly fashion.

Flo
  • 1,469
  • 1
  • 18
  • 27
1

LocationManagers pose a very difficult way to program something that you need. Google has reinvented its location providers to fuse them with sensors. Its the latest and best, uses less battery and does magic with your application, by removing all the 1000's of lines of useless code that you need to write between your gps / network providers.

The new api's are LocationClient api's. Watch this video and demo for yourself.

Siddharth
  • 9,349
  • 16
  • 86
  • 148
1

you can use new geo fence api provided by the Google recently,its more power efficient https://developer.android.com/training/location/geofencing.html

RAHULRSANNIDHI
  • 527
  • 6
  • 20