Battery drain — one of the most common complaints from mobile app users. An app begins consuming abnormally high energy, causing the device to discharge quickly even in the background. According to Google I/O 2023, up to 30% of apps on Google Play have energy consumption issues that directly affect user retention. In this article, we'll explore the causes, diagnostics, and optimization methods.
Key Takeaways
Battery drain is a condition where a mobile app consumes significantly more energy than expected under typical usage scenarios. The user notices the device discharges 20-30% faster after installing or updating an app.
Modern mobile OS — Android and iOS — have built-in energy consumption control mechanisms. Android uses Battery Optimization, and iOS uses Background Modes. However, improper API usage can bypass these mechanisms.
According to Purdue University research (2021), about 60% of apps consume energy for background tasks without obvious need. This is especially common in apps with ads, analytics, and persistent network connections.
Energy consumption is measured in mA·h (milliampere-hours). Android provides data through the BatteryManager API, which tracks consumption by each component: CPU, radio module, GPS, display, and sensors.
val batteryManager = getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val chargeCounter = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
val capacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
// chargeCounter / capacity * 100 = current charge percentage
The BatteryManager API allows you to get the current charge and battery capacity, but does not provide per-app details — system utilities are needed for that.
WakeLock — the most dangerous mechanism for the battery. If an app holds a WakeLock without releasing it, the device does not enter sleep mode. Each hour of holding a WakeLock consumes about 50-80 mA·h.
Unbatched network requests are the second most common cause. Every time an app establishes a network connection, the radio module transitions from power-saving mode to active mode. Frequent short requests at intervals of less than 5 minutes keep the radio module constantly active.
High-accuracy GPS location (GPS_PROVIDER) consumes 10-15 times more energy than approximate location (NETWORK_PROVIDER). Constant location updates in the background are one of the most common user complaints.
According to Android Developers Blog, the average app consumes about 15% of the device's total battery drain. Exceeding this level requires mandatory energy consumption auditing.
Battery Historian — Google's official tool for energy consumption analysis. It takes BatteryStats dumps from ADB and visualizes consumption by component: CPU, Network, GPS, WakeLock, and Display.
To create a dump, run the command: adb shell dumpsys batterystats. After collecting data for 2-3 hours of normal usage, you can upload the report to Battery Historian for analysis.
Android Energy Profiler in Android Studio tracks energy consumption in real time. It shows CPU, Network, GPS, and Display consumption for each app operation.
# Reset battery stats before test
adb shell dumpsys batterystats --reset
# Use the app for 2-3 hours
# Export dump for Battery Historian
adb shell dumpsys batterystats > batterystats_dump.txt
For iOS, Energy Log via Xcode Instruments is used. It collects energy consumption data broken down by module: CPU, Network, GPU, Display, Location. Reading time: 15-30 minutes per session analysis.
On a physical iOS device, energy consumption statistics are also shown in Settings > Battery. If an app is in the top 10 for consumption, it's a signal for optimization.
WorkManager — the standard API for background tasks that considers battery state, network, and Doze mode. It guarantees task execution under optimal conditions rather than immediately, saving up to 40% energy on background operations.
val workRequest = OneTimeWorkRequestBuilder<SyncWorker>()
.setConstraints(
Constraints.Builder()
.setRequiresCharging(true)
.setRequiresBatteryNotLow(true)
.setRequiresNetworkType(NetworkType.CONNECTED)
.build()
)
.build()
WorkManager.getInstance(this).enqueue(workRequest)
Request batching — combining multiple network operations into one communication session. Instead of 10 separate requests, the app makes one batch request, reducing radio module active time from 30 seconds to 2-3 seconds.
FusedLocationProviderClient from Google Play Services selects the optimal location source based on required accuracy. For background tasks, use PRIORITY_BALANCED_POWER_ACCURACY priority — this provides accuracy up to 100 meters with minimal battery drain.
On iOS, use Significant Location Change instead of Continuous Location. This allows updates only on significant movement (more than 500 meters), rather than every few seconds.
Android Battery Historian — Google's web tool for BatteryStats data visualization. Supports dump import, color-coded components, and session comparison. Key metrics: WakeLock hold time, radio module activity, GPS sessions.
Xcode Energy Organizer collects energy consumption data from production users via TestFlight and App Store. You get a report on average consumption across different devices and iOS versions. This allows tracking regressions after updates.
PerfDog (Tencent) — a cross-platform performance testing tool that includes energy consumption measurements. Supports iOS and Android, allows recording metrics at 1-10 frames per second.
| Tool | Platform | Metrics |
|---|---|---|
| Battery Historian | Android | WakeLock, Network, GPS, CPU, Display |
| Energy Profiler | Android Studio | CPU, Network, GPS, Radio in real time |
| Energy Log | iOS (Xcode) | CPU, Network, GPU, Display, Location |
| PerfDog | iOS + Android | Energy, FPS, CPU, Memory (all together) |
According to Apple WWDC 2023, using Energy Organizer reduces average app energy consumption by 15-25% by identifying and fixing regressions before an App Store release.
Frequently Asked Questions
Social networks and messengers (Facebook, Instagram, WhatsApp, Telegram) traditionally lead in energy consumption. They constantly sync data, update feeds, receive push notifications, and use GPS. In second place are 3D graphics games that load both GPU and CPU simultaneously, consuming up to 400-600 mA·h per hour of active gameplay.
Yes, directly. The screen is the most energy-intensive smartphone component. Increasing the refresh rate from 60 Hz to 120 Hz increases display energy consumption by 30-50%. However, modern LTPO displays dynamically change the frequency from 1 to 120 Hz depending on content, reducing the impact on the battery.
High-accuracy GPS consumes about 200-300 mA·h per hour of continuous operation. For comparison, location determination via Wi-Fi and cell towers (NETWORK_PROVIDER) consumes only 20-40 mA·h over the same period. Use the Geofencing API to enable GPS only when entering a specified area.
No. Modern OS (Android and iOS) optimize background processes themselves. Force-closing an app and restarting it consumes more energy than if the app remained in the background. The exception is apps that explicitly cause problems (determined via battery statistics in settings).
Open Settings > Battery > Battery Usage. The system will show a list of apps with consumption percentages. For detailed analysis, use ADB: adb shell dumpsys batterystats and upload the dump to Battery Historian. This will show not only total consumption but also a breakdown by components (WakeLock, Network, GPS).
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also