0

I am developing a location based android application which requires to retrieve location continuously in background.

  • I am using a LocationManager for fetching location updates.
  • I have written a service that implements the LocationListener and retrieves the location updates.
  • There is an option provided to user to either turn on/off notifications. If notifications are off, I am calling stopService() when my app goes in background otherwise service keeps on running and mLocManager.removeUpdates() is not called.

This means if user keeps notification on, the service will go on requesting location updates. My biggest concern right now is battery drain. I know I must stop requesting updates at some point but my app needs receiving location continuously in background. Can anyone tell me how much average battery location updates may drain when I am using NETWORK_PROVIDER and requesting updates at an interval of 5 mins?

Also should I use LocationClient instead of LocationManager in order to improve performance? Or will it be ok if I continue with LocationManager.

It would really be great if someone could provide me a suggestion on how to efficiently receive location updates in app which continuously requires location data.

Raeesaa
  • 3,267
  • 2
  • 22
  • 44
  • have a look at he following link http://stackoverflow.com/a/14478281/1292203 – Usman Kurd Oct 28 '13 at 06:41
  • I am already using service for retrieving the location in background. But I need to receive location updates continuously in background, so I am not calling stopService() which I know won't be a good practice and will drain battery. Is there any efficient way to receive location updates continuously in background without draining battery much? – Raeesaa Oct 28 '13 at 06:46
  • 1
    It would really be great if someone could suggest me an efficient way for requesting continuous updates with less battery drain. – Raeesaa Oct 29 '13 at 08:40

3 Answers3

1

LocationClient is part of Google Play Services and I believe Location Client is the more efficient in getting the location with minimal energy(battery drain) with greater accuracy.

And also refer APIs :) http://developer.android.com/reference/com/google/android/gms/location/LocationClient.html

http://developer.android.com/reference/android/location/LocationManager.html

Jayasagar
  • 2,046
  • 19
  • 22
0

You have to remember that LocationClient is part of Google Play Services, so it's only available on devices whose platform includes Google Play Store. Some devices may be using a non-standard version of Android, and you won't have access to LocationClient.

Himanshu Joshi
  • 3,391
  • 1
  • 19
  • 32
  • Yes I am aware of this. That's the reason I am using LocationManager. My biggest concern right now is battery drain and as far as I know LocationClient uses less power than LocationManager that's why I was planning to switch to LocationClient. – Raeesaa Oct 28 '13 at 06:41
  • Location Manager was introduced in Android SDK and can be used as a feature of android. Location Client is something that's part of Google Play SDK and is introduced in the recent Google IO 2013. One can understand that since Location Client is the latest, it is more efficient in getting the location with minimal energy(battery drain) with greater accuracy. – Himanshu Joshi Oct 28 '13 at 06:43
0

Requesting location updates using NETWORK_PROVIDER and updating the location every 5 mins is just okay. But the accuracy of the location is degraded if you compare it with GPS_PROVIDER but then again gps needs more power. As a personal experience that I had yesterday, my GPS was constantly on for 3 hours tracking my location every 10 seconds, I had a battery drain of 20% in that time using Nexus 4. Rest you can choose fro yourself if it is acceptable to you or not.

But as others have mentioned, using FusedLocation Provider that is LocationClient is the best alternative to the accuracy vs battery drain problem.

d3m0li5h3r
  • 1,957
  • 17
  • 33
  • Thank you for your answer. I am still confused about what to use. Will have to discuss this with few people before coming to conclusion. – Raeesaa Oct 28 '13 at 07:14
  • 1
    yes.. that's the best way to do something.. ask the devs what they prefer and why they prefer. you'll learn a lot that way. – d3m0li5h3r Oct 28 '13 at 07:16