Madan Ankapura, Android Product Manager

Battery performance and battery life are a concern for many users — your device can drain power too quickly and your application will be unavailable to users. Good battery management is therefore important to maintaining good customer relationships, and Android has introduced a number of features in iterations to help developers tackle this challenge.

In terms of improving security and performance, Google Play’s official policy adds the following: The target API level of all apps should not differ more than one year from the current version of Android. Every Update to the Android platform brings security and performance enhancements, and adapting apps to the latest API levels ensures that they benefit from these latest optimizations. In addition, when updating API levels, it is important to accurately evaluate the foreground and background requirements of your application, as such requirements can have a significant impact on device life and performance.

Let’s take a look at the evolution of Android’s power management features and see how each version of Android has helped improve battery life:

  • Starting with Android 5.0 Lollipop, developers can use Job Scheduler to postpone tasks.
  • Starting from Android 6.0 Marshmallow, when the user has not used the device or application for a period of time, the device enters power saving or low power consumption mode, and the system suspends network access and postpones synchronization and other background tasks.
  • Power Saving mode is a significant improvement in Android 7.0 Nougat, enabling a second level of system activity restriction after the screen is off and the device has been stationary for a certain amount of time.
  • Android 8.0 Oreo introduced Background limits to prevent apps from running services in the Background and reduce the frequency with which apps get device location updates.

The Android 9 Pie further enhances the device’s power management capabilities based on three principles:

1. Help developers build great apps

2. Improve application power efficiency

3. Users do not need to set application configuration

This means that the OS needs to become smarter, adapting to user preferences while improving device life. To achieve these goals, Android has introduced features such as app standby classification and background restrictions, as well as improved power saving assistant features. Developers are advised to test their apps on Android 9 Pie devices with the above features enabled.

Power-saving Assistant and power-saving mode optimise the system globally, while dynamic power management (application standby grouping driven by DeepMind machine learning) and background limits manage power only at the application level. You can get a better idea of how Android schedules tasks:

Meet Google Play target API Level Requirements

Allocating resources to the right design patterns and architectures is critical for developers, so we recommend that you adopt the following strategies in your development process:

1. Ensure that the application that the user is using completes the necessary work

2. Allow postponement of background work or tasks

3. Use the foreground service, but allow the user to stop the running foreground service by clicking a message notification

Other core basic functions of the OS are also limited, such as the standard alarm, network, and FCM information. You are advised to refer to the Power Management Limits for details. In addition, if you want a more thorough understanding of each power management feature, check out our shared and DevByte power management tutorial at Google I/O Developer Conference, or check out the Power Optimization Developer Documentation.

We’ll be releasing a series of development guidelines on design patterns in the coming weeks, so stay tuned!

Thank you: The Battery Management series is a collaborative effort between the Android Framework team and the DevRel team. Thank you for your valuable contribution!

This text links: android-developers.googleblog.com/2018/09/moa…