Nowadays, users rely on their mobile devices for everything and have n number of applications on their devices for the same. Managed poorly, these applications can lead to faster battery drainage.
In any application, one of the most significant sources of battery drainage is data transfer over the wireless radio. Beyond the power needed to send and receive data, these radios spend extra power just turning on and keeping awake. And in this article we will understand how to reduce the battery drainage due to network activity.
Before we jump to the ways of reducing the battery drainage, lets understand what happens under the hood, when we make any network call.
The Radio State Machine
The wireless radio on a device has built-in power-saving features that help minimize the amount of battery power it consumes. When fully active, the wireless radio consumes significant power, but when inactive or in standby, the radio consumes very little power.
Logic behind all radios is same but let’s consider a 3G network radio as an example. The state machine for a typical 3G network radio consists of three energy states:
- Full power: Used when a connection is active, allowing the device to transfer data at its highest possible rate.
- Low power: An intermediate state that cuts battery power consumption by around 50%.
- Standby: The minimal power-consuming state during which no network connection is active.
Whenever a network call is made, the state machine goes in full power state. If the state machine is in low power or standby state and you make a call, the radio takes some time to move to fully active mode. This is the latency period for “powering up” the radio.
A 3G Radio can go from low power to full power in 1.5 seconds and from standby to fully active in 2 seconds.
To minimize latency, the state machine uses a delay to postpone the transition to lower energy states. This means that even after a network call has been made, the radio will remain in full power mode for a few more seconds so that you can make any other call if required before moving to low power state.

Now let’s see how is the battery performance affected when we make our network calls. Let’s compare 2 cases:
Case 1 : We make 3, 1 second network calls at different intervals
Case 2 : We bundle the 3 calls and make a 3 second call instead
Which one do you think will offer better performance?
Our first thought would be that 3 different calls means smaller payloads which in turn means lesser time to get the response so will this offer better performance? Actually no, it’s the other way round. A bundled call will gives us a better performance. Let’s see how?
When we make three 1 second calls at different intervals, this is how our system looks like.

Making a one second data transfer, three times will keep the radio active for almost a minute because it will be needed to move to full power just as it is entering the stand-by mode.
By comparison, if the same app bundled its data transfers, running a single three-second transfer every minute, this would keep the radio in the high-power state for a total of only 20 seconds each minute. This would allow the radio to be on standby for 40 seconds of every minute, resulting in a significant reduction in battery consumption.

Improve battery life
Now that you understand how network calls affect affects battery life, let’s talk about a few things that you can do to help reduce battery drainage, while also providing a fast and fluid user experience.
Bundle Data Transfer
As stated in the previous section, bundling your data transfers so that you’re transferring more data less often is one of the best ways to improve battery efficiency.
Prefetch Data
You can anticipate which data will be needed in the next series of user actions and fetch that data in a single burst, over a single connection, at full capacity.
While prefetching data carries a lot of benefits, used too aggressively prefetching also introduces the risk of increasing battery drain and bandwidth use by downloading data that isn’t used. It can even delay the app startup time so you can follow a few general rules:
- It’s good practice to prefetch data such that you will only need to initiate another download every 2 to 5 minutes, and in the order of 1 to 5 megabytes.
- Large downloads — such as video files — should be downloaded in chunks at regular intervals (every 2 to 5 minutes), effectively prefetching only the video data likely to be viewed in the next few minutes.
- Try scheduling the full download to occur only when connected to Wi-Fi, and possibly only when the device is charging. (WorkManager API can be used for the same)
Check for connectivity before making requests
Searching for a cell signal is one of the most power-draining operations on a mobile device. A best practice for user-initiated requests is to first check for a connection using ConnectivityManager . If there’s no network, the app can save battery by not forcing the mobile radio to search.
Pool Connections
An additional strategy that can help in addition to batching and prefetching, is to pool your app’s network connections.
It’s generally more efficient to reuse existing network connections than it is to initiate new ones. Reusing connections also allows the network to more-intelligently react to congestion and related network data issues.
HttpURLConnection and most HTTP clients, such as OkHttp, enable connection-pooling by default, and reusing the same connection for multiple requests.
That’s it for this article. Hope it was helpful!
These are some general tips to optimize your battery performance. In the next article, I will explain what tips to follow for what kind of requests.
