2. Apps are to blame the most for bad battery
life
Power Bugs
3. • Bad coding patterns cause power bugs
• Specific behaviors of the Android Platform
• App inter-dependencies!
• Special Attention must be paid to optimize
for power!
Power Bugs
11. • Registering for un-necessary events
• Waking up the system causes everyone to
be woken up
• Register for “active” notifications (instead
of passive ones)
• Handset-specific problems
More Types Of Power Bugs
13. Jeff Sharkey at Google IO
Power Consumption is Complex and Inter-dependent
among components
14. • prefetch data
– to avoid switching states frequently, try and read as
much data as possible
– trade-off between too much pre-fetch and battery
drain
– google recommends pre-fetching data that you will
initiate in the next 2 to 5 minutes, and in the order of
1-5 MB size
• batch data
– do data send/receive in batches rather than on-
demand
Best Practices - Network
– eg: batch analytics information, rather than sending
them as they are collected
15. • using inexact timers
– AlarmManager.setInexactRepeating()
– use ELAPSED_REALTIME instead of
ELAPSED_REALTIME_WAKEUP
• detect network connection
– avoid connection attempts if no network is active
• avoid polling and use GCM when possible
– avoids multiple connections
– reduces the number of device state changes
Best Practices - Network
16. • color matters!
– esp on OLED
screens
– darker the color,
lesser the
consumption
• brightness levels
have more impact
– refer to -
http://stackoverflow.com/qu
estions/5032588/cant-
apply-system-screen-
brightness-
programmatically-in-
android
Best Practices - Screen
17. • programmatically
reduce brightness
if its suits your
app/activity
• Use “night mode”
for reading Apps
• Think about your
color scheme
Best Practices - Screen
18. • wakelocks are your
friend, but your users
worst nightmare!
• use them only if really
needed and ensure they
are removed as soon as
possible
• Use
‘android:keepScreenOn’
property in your manifest
instead of doing it
programmatically
Best Practices - CPU
19. • if possible, spread out
your computationally
intensive job
• gpu typically consumes
more power than cpu
– avoid floating point math
where possible
• use algorithms that
consume less CPU cycle
– O(n log n) vs O(n 2)
algorithms
Best Practices - CPU