

Battery Optimization for Android Apps - vinnyglennon
http://www.slideshare.net/MuratAydn3/battery-optimization-for-android-apps-devoxx14

======
kec
One other thing this deck doesn't go into but has a huge impact (for games at
least) is frame rate. Higher frame rates require the GPU to get the work done
in a shorter amount of time and make it less likely that the GPU will be able
to switch to an idle power save state.

A good example of this in action is the game Threes. The developers
implemented a "power save" feature in the game which simply cuts the frame
rate in half[0], causing the app to consume noticeably less battery.

0: [http://asherv.com/threes/support/](http://asherv.com/threes/support/)

~~~
corysama
I worked on a mobile FPS that was able to run at full-rez, 60fps on an iPad3.
Unfortunately, doing so drained the battery faster than the wall charger could
refill it! So, we shipped locked at 30fps and provided a "battery hog mode"
option to the user.

~~~
snuxoll
What level was the battery at? Past 80% most Lithium Ion or Lithium Polymer
battery controllers will change to a trickle charge which could explain it.

~~~
corysama
You could drain the battery completely while charging.

~~~
voltagex_
Ingress will do this on a Nexus 5 - except for wall chargers that are
delivering the full ~1.7A (which are very very very few)

~~~
fixedd
Ingress can do this on a Galaxy Nexus with a 2A external battery pack (or, ya
know, car). I was only able to help with about 1/2 of an Interitus event cause
my phone kept dying and I'd have to wait a bit to bring it back online.

I hate my phone.

------
zxcvgm
I thought this slide deck would cover the improvements introduced by Project
Volta [1] in Lollipop. They introduced a JobScheduler API that developers can
use to perform the batching that he described, as well as the Battery
Historian for better power profiling.

[1]
[https://developer.android.com/about/versions/android-5.0.htm...](https://developer.android.com/about/versions/android-5.0.html#Power)

~~~
christop
On that topic, this is a much better talk:
[http://commonsware.com/presos/8469_Murphy.pdf](http://commonsware.com/presos/8469_Murphy.pdf)

------
dkopi
I really hope Google one day adds a "battery usage" and "network usage" rating
for apps in the play store. Common users are pretty helpless when it comes to
figuring out which apps are killing their phone.

~~~
edude03
Better yet, I hope google exposes "battery historian" via the battery menu on
android phones.

~~~
shitlord
Yeah, the fact that we Android users need to use apps like Better Battery
Stats is pretty telling. They could at least stick it in the developer
settings somewhere.

------
yardie
Why is any of this even necessary at this stage. Android has been around for 7
years, 5 major versions, and many more subversions. Power management should be
solved by now. The OS should be managing this. All power management options
should be applied to all apps and only those that need an exemption should
code around it.

~~~
cryptoz
It's a balancing act between giving devs power over their code and managing
battery. You could say that Apple 'solved' the problem by preventing
developers from doing really cool things, whereas Google/Android still have
battery concerns but devs have built awesome apps that depend on that
flexibility.

This isn't something than can be 'solved'. All the time, Google will make
improvements to the OS (like JobScheduler in Lollipop) and devs will get
better at managing their resources. Slowly we'll all get better battery
performance.

I make PressureNet, which runs in the background on Android in 10-minute
intervals to get GPS, barometer measurement, and network lock. Maintaining a
good battery life isn't easy, but it is possible.
[https://play.google.com/store/apps/details?id=ca.cumulonimbu...](https://play.google.com/store/apps/details?id=ca.cumulonimbus.barometernetwork)

~~~
lpsz
Devs can still have all the power, as long as excessive battery usage is more
transparent to users. I'm not sure about iPhone, but OS X has an indicator
with "Apps Using Significant Energy." [1] as well as a more detailed breakdown
[2]. Very useful. Often turns out to be a stray tab in Chrome. Would like to
see something like that.

[1] [http://support.apple.com/en-us/HT5873](http://support.apple.com/en-
us/HT5873)

[2]
[http://support.apple.com/library/content/dam/edam/applecare/...](http://support.apple.com/library/content/dam/edam/applecare/images/en_US/osx/yosemite-
activity_monitor-energy.png)

~~~
dbaupp
Android does have something similar:
[http://imgur.com/a/d2nCb](http://imgur.com/a/d2nCb)

------
joosters
An ad/tracker/stats blocker sounds like it might give your battery life a huge
boost here. Think of the network traffic saved!

------
voltagex_
Also [https://developer.android.com/training/monitoring-device-
sta...](https://developer.android.com/training/monitoring-device-
state/index.html)

