Background Limitations in Android

Yevhenii Smirnov
Yevhenii Smirnov
Dec 13 2024
Posted in Engineering & Technology

What happens to your App in the background?

Background Limitations in Android

In modern mobile operating systems like Android, conserving battery life is a top priority. To achieve this, Android imposes strict limitations on what apps can do in the background. While these restrictions are essential for preserving device performance and battery health, they pose challenges for developers who want their apps to provide seamless user experiences.

Why Background Limitations Exist?

Android has one simple goal, to make sure your phone lasts as long as possible on a single charge. To help achieve this, Android restricts what apps can do in the background.

Apps that constantly run tasks, sync data, or keep the CPU awake use a lot of power, which can quickly drain a device’s battery. These limitations are crucial for maintaining both battery life and system performance, but they also present challenges for developers who want to create apps that perform well at all times.

Standby Buckets

One of the primary ways Android limits background activity is through App Standby Buckets. The system classifies apps into different buckets based on how frequently they are used and how important they are to the user.

  • Active: Apps in this bucket are being used right now or very recently used, so they face no restrictions.
  • Working Set: These are apps the user has recently interacted with but isn’t active. They have some mild restrictions on its ability to run jobs and trigger alarms.
  • Frequent: These apps are used on a regular but not constant basis. They have stronger restrictions on its ability to run jobs and trigger alarms.
  • Rare: Apps that the user rarely interacts with. They have strict restrictions on its ability to run jobs and trigger alarms. The system also limits the app's ability to connect to the internet.
  • Restricted: This bucket, added in Android 12, has the lowest priority and the highest restrictions of all the buckets.

Doze Mode

Doze Mode is an Android feature designed to extend battery life by reducing the power used by apps when the device is idle and not connected to power source. Once activated, Doze Mode limits background processes, such as:

  • Network Access
  • WakeLock's
  • Standard Alarms
  • Wi-FI Scans
  • JobScheduler (also WorkManager as it uses JobScheduler internally)

Adapting your App

Adapting to Android’s power-saving features requires careful planning and optimization. To ensure your app runs smoothly under Doze Mode and App Standby Buckets, focus on scheduling background tasks to fit within the system’s restrictions. Tools like WorkManager can help align operations with maintenance windows, allowing essential updates to occur efficiently.

User engagement is crucial for maintaining your app in higher priority buckets, so design features that encourage regular interaction.

Thorough testing is crucial to ensure your app performs reliably under power-saving constraints. Simulate Doze and App Standby conditions using ABD to ensure every feature in your app is working as expected under.

Alternatively, a straightforward approach for testing, such as testing a network request, may be the opposite. You may discard if the issue is caused by power management limitations by going into App Settings -> Battery Usage -> Allow Background Usage and selecting Unrestricted, ensuring your app is partially exempt from Doze and App Standby optimizations.

Dive Deeper

While this is a summary of the most critical points, I would like to invite you to take a deeper dive and discover all details in the official docs:

What's About Us?

This is something not only your app should be aware of, but also something our SDK is designed to handle effectively. It ensures that relevant events and information are not lost, even under those restrictions. Our SDK helps maintain seamless functionality and delivers a smooth and reliable experience.

As always, we are available via our Support Channel for any question you might have.

Keep up-to-date with the latest news