20.08.2016 Views

Professional Android 4 Application Development

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

220 x CHAPTER 6 USING INTERNET RESOURCES<br />

Every time you create a new connection to download additional data, you risk waking the wireless<br />

radio from standby mode to active mode. In general, it’s good practice to bundle your connections<br />

and associated downloads to perform them concurrently and infrequently.<br />

To use a converse example, creating frequent, short-lived connections that download small amounts<br />

of data can have the most dramatic impact on the battery.<br />

You can use the following techniques to minimize your application’s battery cost.<br />

‰ Aggressively prefetch — The more data you download in a single connection, the less frequently<br />

the radio will need to be powered up to download more data. This will need to be<br />

balanced with downloading too much data that won’t be used.<br />

‰ Bundle your connections and downloads — Rather than sending time-insensitive data<br />

such as analytics as they’re received, bundle them together and schedule them to transmit<br />

concurrently with other connections, such as when refreshing content or prefetching data.<br />

Remember, each new connection has the potential of powering up the radio.<br />

‰ Reuse existing connections rather than creating new ones — Using existing connections<br />

rather than initiating new ones for each transfer can dramatically improve network<br />

performance, reduce latency, and allow the network to intelligently react to congestion<br />

and related issues<br />

‰ Schedule repeated downloads as infrequently as possible — It’s good practice to set the<br />

default refresh frequency to as low as usability will allow, rather than as fast as possible. For<br />

users who require their updates to be more frequent, provide preferences that allow them to<br />

sacrifice battery life in exchange for freshness.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!