Android - Is there a way to exclude an app from Doze?

This answer is based off my Nexus 9 on MRA58K. It should be similar for any app.

Follow the steps as given below:

  1. Go to Settings → Battery

  2. Tap on the top right 3-dot menu, and choose Battery Optimisation.

  3. There should be a dropdown below the actionbar on the top left, choose All Apps from the list.

  4. Find your app in the list (in this case, Whatsapp)

  5. Tap on it. You will get a popup with 2 options, Optimise and Don't Optimise

  6. Optimise should be selected by default.

  7. Select "Don't Optimise", and press "Done" below.

  8. That's it. I hope it works for you.


The instructions provided by Tamoghna are the easiest ones to follow when it comes to doing something from GUI. However, there exists other ways to achieve the goal.

You can use the system service named deviceidle to manipulate the battery optimization for an app. You would need adb setup in PC. Once you have the latter, execute:

adb shell dumpsys deviceidle whitelist +PACKAGE

Replace PACKAGE with package name of the app which you intend to exclude from Doze mode. Follow View app's full package name? if you do not know the package name of your app.

To revert changes, replace + with - in the said command and execute it.

An example, performed for Kde Connect app:

IMG

Note that both the GUI and command-line method make changes in the file /data/system/deviceidle.xml. If you're up to the task and have root access, you can edit that file, reboot the device and your app would be found under "Not Optimized" tab of Battery Optimization.

I came to know about that command from this question by user2281606. I was also reading Optimizing for Doze and App Standby - Testing your app with Doze.


If you want your app permanently removed from optimization and if you have root access, you can just add a simple xml-file to your system partition:

Create a *.xml file with any name and add following content:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <allow-in-power-save package="com.your.package.name" />
    <allow-in-power-save-except-idle package="com.your.package.name" />
</config>

Remount your system partition mount -o remount,rw /system and copy the file to your /system/etc/sysconfig/ folder. You may also remove the preinstalled *.xml files to disable the forced system services.