1 page.title=Optimizing for Battery Life 2 page.metaDescription=Learn how to help your app go easier on the battery. 3 4 meta.tags="performance" 5 page.tags="performance" 6 7 @jd:body 8 9 <div id="qv-wrapper"> 10 <div id="qv"> 11 <h2> 12 In this document 13 </h2> 14 <ol> 15 <li> 16 <a href="#lazy">Lazy First</a> 17 </li> 18 <li> 19 <a href="#features">Platform Features</a> 20 </li> 21 <li> 22 <a href="#toolery">Tooling</a> 23 </li> 24 </ol> 25 </div> 26 </div> 27 28 <p>Battery life is the single most important aspect of the mobile user 29 experience. A device without power offers no functionality at all. 30 For this reason, it is critically important that apps be as respectful of 31 battery life as possible.</p> 32 33 <p>There are three important things to keep in mind in keeping your app 34 power-thrifty:</p> 35 <ul> 36 <li>Make your apps <em>Lazy First</em>.</li> 37 <li>Take advantage of platform features that can help manage your app's battery 38 consumption.</li> 39 <li>Use tools that can help you identify battery-draining culprits.</li> 40 </ul> 41 42 <h2 id="lazy">Lazy First</h2> 43 44 <p>Making your app Lazy First means looking for ways to reduce and optimize 45 operations that are particularly battery-intensive. The core questions 46 underpinning Lazy First design are: 47 48 <ul> 49 50 <li><strong>Reduce:</strong> Are there redundant operations your app can cut 51 out? For example, can it cache downloaded data instead of repeatedly waking 52 up the radio to re-download the data?</li> 53 54 <li><strong>Defer:</strong> Does an app need to perform an action right 55 away? For example, 56 can it wait until the device is charging before it backs data up to the 57 cloud?</li> 58 59 <li><strong>Coalesce:</strong> Can work be batched, instead of putting the 60 device 61 into an active state many times? For example, is it really necessary for 62 several dozen apps to each turn on the radio at separate times to send 63 their messages? Can the messages instead be transmitted during a 64 single awakening of the radio?</li> 65 </ul> 66 67 <p> 68 You should ask these questions when it comes to using the CPU, 69 the radio, and the screen. Lazy First design is often a good way 70 to tame these battery killers. 71 </p> 72 73 <p> 74 To help you achieve these and other efficiencies, the Android platform 75 provides a number of features to help maximize battery life. 76 </p> 77 78 <h2 id="features">Platform Features</h2> 79 80 <p> 81 Broadly speaking, the Android platform provides two categories of help 82 for you to optimize your app's battery use. First, it provides several 83 APIs that you can implement in your app. You can learn more about these APIs in 84 <a href="/topic/performance/scheduling.html">Intelligent Job Scheduling</a> 85 and <a href="/performance/power/network/index.html"> 86 Network Use and Battery Consumption</a>. 87 </p> 88 89 <p> 90 There are also internal mechanisms in the platform to help conserve 91 battery life. While they are not APIs that you implement programmatically, 92 you should still be aware of them so that your app can leverage them 93 successfully. For more information, see 94 <a href="/training/monitoring-device-state/doze-standby.html">Doze and 95 App Standby</a>.</p> 96 97 <p> 98 You can get even more benefit out of these features by using the tools 99 available for the platform to discover the parts of your app that consume 100 the most power. Finding what to target is a big step toward 101 successful optimization. 102 </p> 103 104 <h2 id ="toolery">Tooling</h2> 105 106 <p>There are tools for Android, including 107 <a href="/studio/profile/dev-options-rendering.html">Profile GPU Rendering</a> 108 and <a class="external-link" 109 href="https://github.com/google/battery-historian">Battery Historian</a> 110 to help you identify areas that you can optimize for better battery life. 111 Take advantage of these tools to target areas where you can apply the 112 principles of Lazy First. 113 </p> 114 115 <section class="dac-section dac-small" id="latest-games"><div class="wrap"> 116 <h2 class="norule" style="margin:0 0">More resources</h2> 117 <div class="resource-widget resource-flow-layout col-16" 118 data-query="collection:develop/performance/landing" 119 data-sortOrder="random" 120 data-cardSizes="6x6" 121 data-maxResults="24" 122 data-items-per-page="24" 123 data-initial-results="3"></div> 124 </div> 125 </section> 126