Niju Mt
Niju Mt

Reputation: 159

Android GPS and battery usage

I have 2 android applications A and B, and both of them are reading gps values based on different parameters. Considering both the apps are running on the device, which of the folllowing approaches would be better?

  1. Both A and B are to be different apps, each one with a component to read from GPS.

  2. To develop a third application with a remote service component to transmit GPS data to both A and B

Would battery usage be minimized by going for the second approach or will the GPS component read once and serve all processes, as in the OS?

Please help

Upvotes: 2

Views: 7253

Answers (5)

Harshal Benake
Harshal Benake

Reputation: 2401

Second approach seems to be more appropriate but not sure about battery drainage.It depends upon how you implement it.

Also I would suggest try to use passive providers.Refer following link help it works :)

http://fypandroid.wordpress.com/2011/04/11/298/

Upvotes: 0

Kostis
Kostis

Reputation: 1705

I think the most battery-efficient way would be to poll the GPS location with app A normally, and in app B, use LocationRequests and use setPriority() with PRIORITY_NO_POWER. As mentioned in the docs, PRIORITY_NO_POWER will make app B get updates only when another app gets GPS updates (in this case, app A!!). I haven't tried it, but it should work. It definitely saves you the hassle of an extra app :)

Some more info on Google Play Location Services here and here.

Upvotes: 2

zeiddiez
zeiddiez

Reputation: 62

For the sake of compatibility and function I would suggest having a third process or program which reads and outputs GPS data, as multiple processes polling data from GPS is less efficient.

It would also be faster to have those two apps read the output of a single GPS tracking app and not needing individual components in each app to do so.

For the sake of power the GPS will use the same level of power regardless, though if it's polled more often due to two applications using it then it may use more - though the amount is likely to be minimal unless there are constant requests for location.

Though this may not be the question it would be most power efficient to have the third application poll GPS at specific intervals and the applications may read from its output rather than search location every time.

Upvotes: 0

Jitender Dev
Jitender Dev

Reputation: 6925

There is a very good explanation given in the Android Developers Website about Location Strategies. I would suggest you to take a look at the code examples on the page.

In both of your approaches i believe second approach is quite better because Turning on/off GPS is a quite expensive operation in terms of battery usage.

GPS’s battery draining behavior is most noticeable during the initial acquisition of the satellite’s navigation message. Acquiring each satellite takes 12 to 30 seconds, but if the full almanac is needed, this can take up to 12 minutes. During all of this, your phone is unable to enter a deep sleep. A-GPS (Assisted GPS) partially solves this, by sending the navigational message to your mobile device over your cellular data network or even Wi-Fi. As the bandwidth of either of these greatly dwarves the 50bps of the GPS satellites, the time spent powering the GPS antenna or avoiding deep sleep is greatly reduced.

Referred from this.

Upvotes: 5

AlexWien
AlexWien

Reputation: 28727

is it the same as OS gPS component will run once to serve all

One GPS serves all. There is no half GPS saving half the power. But there are other location providers like cell tower and Wifi locationing which uses less power.

But if you need GPS it is absolutley no difference how many apps uses the GPS service. If GPS is enabled it uses full power.

Upvotes: 0

Related Questions