Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

Excessive Mobile Network Usage in Background

When an app connects to the mobile network in the background, the app wakes up the CPU and turns on the radio. Doing so repeatedly can run down a device's battery. An app is considered to be running in the background if it is in the PROCESS_STATE_BACKGROUND or PROCESS_STATE_CACHED state.

This page explains how to determine why your app is excessively using the mobile network while running in the background, and what to do about it.

Detect the problem

You may not always know that your app is making inordinate use of the network while running in the background. If you have already published your app, Android vitals can make you aware of the problem so that you can fix it.

Android vitals

Android vitals can help improve your app's performance by alerting you, via the Play Console, when your app is performing excessive Wi-Fi scanning n the background. Android vitals considers background network usage excessive when an app is sending and receiving a combined total of 50 MB per hour while running in the background in 0.10% of battery sessions.

A battery session refers to the interval between two full battery charges. For information on how Google Play collects Android vitals data, see the Play Console documentation.

Investigating mobile-network-usage behavior

Tools such as Battery Historian can help you gain more insight into your app's mobile-network usage. Battery Historian provides a visualization of mobile-radio use on a per-app basis, which can help you gain a clearer picture of what's happening with your app. For more information about Battery Historian, see Analyzing Power Use with Battery Historian. In investigating your app's mobile-network-usage behavior, you should take particular note of the Mobile network use line.

For information about the mechanics of using Battery Historian, see Batterystats and Battery Historian Walkthrough.

Reduce mobile network usage

Mobile-network usage may occur because the app is performing syncs. For information on how to reduce syncs, and your network usage along with them, see Excessive Background Syncs.

You can also move your app’s mobile-network usage to the foreground, alerting the user to the fact that a download is in progress, and providing them with controls to pause or stop the download. To do so, call DownloadManager, and set setNotificationVisibility(int) as appropriate.