How does Android determine if an app has "High Battery Use" under "Recent Location Requests"?

Martin Konecny picture Martin Konecny · Nov 16, 2013 · Viewed 15.8k times · Source

As of Kitkat (4.4) Android reports that my app is "High battery use".

I use Network Location as well GPS. If I disable GPS, then it seems the app gets marked as "Low battery use".

I'm wondering if there are any tips to using GPS while keeping the "Low battery use" label. Perhaps if you poll infrequently enough - or is it hardcoded to GPS = battery killer?

EDIT:

I understand that changing those parameters will conserve battery life. My question was more of whether Android will recognize these attempts at battery life conservation or will it simply brand my app as high power usage simply because it uses GPS.

Answer

Shobhit Puri picture Shobhit Puri · Nov 16, 2013

Good question but repetitive. Yes, polling frequency does effect you battery life much. So the frequency of getting the location updates of the user should be tailored according to specific needs.

  1. Basically is you read the android documentation of requestLocationUpdates of LocationManager, it says:

    requestLocationUpdates (long minTime, float minDistance, Criteria criteria, PendingIntent intent)

    Choosing a sensible value for minTime is important to conserve battery life. Each location update requires power from GPS, WIFI, Cell and other radios. Select a minTime value as high as possible while still providing a reasonable user experience. If your application is not in the foreground and showing location to the user then your application should avoid using an active provider (such as NETWORK_PROVIDER or GPS_PROVIDER), but if you insist then select a minTime of 5 * 60 * 1000 (5 minutes) or greater. If your application is in the foreground and showing location to the user then it is appropriate to select a faster update interval.

    The minDistance parameter can also be used to control the frequency of location updates. If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, AND at least minTime milliseconds have passed. However it is more difficult for location providers to save power using the minDistance parameter, so minTime should be the primary tool to conserving battery life.

  2. Please read following for some good answers on knowing how it drains and what can be done to minimize the battery drain:

    Android Regular GPS Polling in Service, maximizing battery life

    What's the most battery-efficient approach of using LocationClient to periodically get updates?

    Good way of getting the user's location in Android

    Save battery power consumed by gps services in android

    Is location provider really a battery drain?

    Battery life if using GPS and background app ios/android

    Keeping a GPS service alive and optimizing battery life

Hope this helps.

Edit: I agree to @ioan. Now you can use Fused Location API to get the location easily and efficiently.