Chapter  7

Maximizing Battery Life

With little power comes great responsibility. Android portable devices run on batteries, and everything your application does draws a certain amount of power from the device's battery. Since most devices are charged at home during the night and will be used during the day when there is no opportunity to recharge the battery, most device owners expect the battery to last at least about 12 hours. Typical usage may cause the battery to drain more quickly: for example, charging stations were available at Google I/O as many were using their devices for periods of time longer than usual during the event.

Even though applications sometimes do not seem to be doing much, it is actually quite easy to draw so much power from the battery that the device runs out of juice in the middle of the day, leaving the user without a phone or tablet for several hours. An application that empties the battery quickly will most likely become a strong candidate for deletion, poor reviews, and possibly lower revenues. As a consequence, you as a developer should try to use as little power as possible and make sensible use of the device's battery.

In this chapter, you learn how to measure battery usage and how to make sure you can conserve power without negatively impacting the user experience, using some of the very things that make Android applications appealing: networking, access to location information, and sensors. You also learn how to work efficiently with more internal components of Android, such as broadcast receivers, alarms, and wake locks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.194.44