Open In App

How to Reduce Battery Usage in Android Application?

The battery life of an Android phone is dependent on many factors, a few of them are, screen brightness, fast processors, apps running in the background, thin bodies, and many more. Being an app developer, all hardware constraints are out of one’s hands and cannot be changed. What an app developer can do is, make changes in the app such that it requires minimum battery usage and doesn’t drain the battery. There are many methods to do so and a few are explained below.

Lazy First  

There are several operations in an app that are very intensive on the battery, they require a large amount of battery and can cause drain issues. In the lazy first method, such operations are reduced and optimized. The main steps in a lazy first method are  



These steps should be used when the app requires CPU time, screen, internet use, etc. The lazy first method can be applied in the app to make it battery efficient.

Power saving methods

Many Power saving methods are introduced by Android in recent times. After Android 6.0 android came up with two big battery saver methods, Doze and App Standby.  



App Standby

When the user doesn’t make a touch in the app for a long time, the system determines that the app is idle now. It also allows the system to determine an app’s idleness when –

  1. The user does not launch the app.
  2. The app does not generate a notification.
  3. The app doesn’t have a process running in the foreground.
  4. It is not a device admin app. These apps always run in the background and can never be terminated or enter into the app standby state. The New Android version allows the user to keep running an app in the background for always.

When the device is plugged into power, all the stand-by apps are released. They are allowed to access network connections and to complete the job that was left before it went into standby mode. There are some exemptions from the stand-by category other than the device admin apps. These are  

  1. Instant messaging or calling app – They use Firebase Cloud Messaging ( FCM) high-priority messages to wake up the app and access the network.
  2. Task automation app – The core function of these apps is to schedule the actions that are automated such as instant messaging and calls.
  3. Peripheral device companion app – The core function of these types of apps is to maintain a continuous connection with the peripheral device in order to provide them with internet access. Example – Apple watch, fitness bands.

How to test the app with app standby

$ adb shell dumpsys battery unplug

$ adb shell am set-inactive <packageName> true

$ adb shell am set-inactive <packageName> false

$ adb shell am get-inactive <packageName>

Article Tags :