What to do if alarms or sleep tracking don’t work?

The core of the problem

Smartphones are getting more and more powerful, but the battery capacity is lagging behind. Vendors are always trying to squeeze some battery saving features into the firmware with each new Android release. With Android 6 (Marshmallow), Google has introduced Doze mode to the base Android, in an attempt to unify battery saving across the various Android phones.

Unfortunately, vendors such as Samsung, Huawei, OnePlus (and more) did not seem to catch that ball and they all have their own battery savers, usually very poorly written, saving battery only superficially.

These battery saving features have lots of side effects. They usually kill long running processes – but don’t care whether the user wants the process to run or not (think sleep tracking).
They also impose arbitrary limits on random things – like how many times can you schedule an alarm during the night. If you go over the limit – boom! No alarm in the morning! That’s what you get for not reading the documentation on vendor modifications (oh wait, there is no documentation).

How to prevent the alarm and sleep tracking from failing? Opt out of the battery savers.

Samsung

Source: Don’t kill my app by Urbandroid

Explanation

UPDATE: We record significantly increased number of app killing on Samsung's Android Pie flavor. The hints show adaptive battery being much more eager than in stock Android.
After 3 days any unused app will not be able to start from background (e.g. alarms will not work anymore). Imagine, you won't use your alarm clock for a the weekend +1 day and bang! no alarms any more and you miss work! We strongly suggest to turn off Adaptive battery and Put apps to sleep options per instructions below.

IMPORTANT: Latest feedback suggests that even when those options get disabled Samsung may re-enable than later after a firmware update!

Yes, Samsung - a dominant vendor in the Android market - is now using one of the nastiest battery saving techniques in the industry. They kill background processes and render alarm clocks and other apps which rely on background processing useless. See below for workarounds.

Solution

Galaxy S9 / S10

Battery optimization is turned on by default. At some unclear moments (maybe on app update, OS update?), the settings also do revert back to the defaults, forcing you to turn them off again and again. Below are walkthrough screenshots for Galaxy S10. Please let us know your feedback about whether it works for S9 (or others) as well. Thanks!

Sleeping apps

Sleeping apps menu is the sniper’s nest for Samsung’s app killing policies. Make sure to follow the instructions very carefully to prevent the apps from being killed.

Checklist:

  • Disable Put unused apps to sleep
  • Disable Auto-disable unused apps
  • Remove your app from the list of sleeping apps
  • Disable background restrictions for your app
1. Start Device care
from phone settings
2. Tap Battery
3. Tap the 3-dot menu > Settings
4. Disable all toggles
(except Notifications)
5. Tap Sleeping apps
6. Wake up all the apps
using the trashcan icon
WARNING: Make sure that Put unused apps to sleep and Auto-disable unused apps is disabled. Otherwise Samsung will put your apps back to sleep after a few days (3 by default) even if you have woken them up manually!

Galaxy S8 (j6ltedx) and later

With the introduction of their flagship Galaxy S8 (and with some earlier experiments), Samsung has introduced a flawed attempt at prolonging battery life called App power monitor.

For your apps to work correctly, please whitelist them in App power monitor.

How to do it:

Open the Settings > Device maintenance > Battery and at the bottom you’ll see a list of your most frequently used apps. You can manage apps individually or in a group by selecting them then tapping the big Save power button. Apps that are sleeping will appear in the Sleeping apps list at the bottom (tap it to expand the list). Scrolling further — all the way to the very bottom — and you’ll find Unmonitored apps. These are apps that you specifically want to exclude (white list) from App power monitor evil reach.

When inside the Unmonitored apps menu, you can tap the 3-dot menu to add or delete apps from the list. Rather than bothering with any of that, you can just turn off the App power monitor feature completely as it has little-to-no impact on battery life and only serves to handicap the normal functioning of your Galaxy phone.

It’s excessive and in some cases downright misleading, using scare tactics to keep you reliant on Samsung’s software when other Android devices get by just fine without it.

On other Samsung phones, the path may look like this:

Phone settings > Applications > select three dot menu (top right corner) > Special Access > Optimize Battery usage > Find your app on the list and make sure that it is not selected.

NOTE: If you enable Edge Lighting for your app, then the app will not be able to wake up your screen. To allow your app to wake up your screen, please remove it from the Edge Lighting applications list.

Huawei

Source: Don’t kill my app by Urbandroid

Explanation

UPDATE: On some phones with EMUI 9+ (Android P+) Huawei introduced a new task killer app called PowerGenie which kills everything not whitelisted by Huawei and does not give users any configuration options. See below how to uninstall it.
We have mixed reviews on Huawei - the PowerGenie app is present on some EMUI 9+ systems, while on others it isn't.

Traditionally Huawei and their Android customization called EMUI belongs to the most troubled on the market with respect to non-standard background process limitations. There are no APIs and no documentation for those extensions. On default settings, background processing simply does not work right and apps working in background will break.

In some of the EMUI versions (we know about EMUI 4 at and we have some reports about EMUI 5 and now the latest EMUI 9) no user accessible settings can prevent the system to break background processing longer than 60 minutes. This is done by an evil custom service called HwPFWService (and in EMUI 9 this is called PowerGenie) developed and bundled with EMUI by Huawei.

Solution

EMUI 9+ devices

Huawei is extremely inventive in breaking apps on their devices. In addition to all the non-standard power management measures described below, they introduced a new task killer app build right into EMUI 9 on Android Pie.

It is called PowerGenie and it kills all apps that are not on its whitelist. You cannot add custom apps on their pre-defined whitelist. This means there is no other way to fix proper app functionality on Huawei than uninstalling PowerGenie.

Unfortunately this is a system app and can only be fully uninstalled using ADB (Android Debug Bridge) Source: XDA.

You need to:

  1. install ADB on your computer

  2. Connect your phone with a data cable

  3. Enable Developer options

  4. Enable USB debugging within Developer options on your phone

  5. Run the following commands on your computer:

adb shell pm uninstall --user 0 com.huawei.powergenie

We did not yet have this confirmed but it is possible you can alternatively just disable PowerGenie in Phone settings > Apps. This setting would need to be re-applied every time you reboot your device.

Please still follow the steps below - Huawei phones usually have multiple powersaving mechanisms.

Also, you may not have PowerGenie on your phone, but your apps may still get killed by another mechanism.

EMUI 6+ devices (and some EMUI 5 devices)

  • Phone settings > Advanced Settings > Battery manager > Power plan is set to Performance
  • Phone Settings > Advanced Settings > Battery Manager > Protected apps – check for your app as Protected
  • Phone Settings > Apps > Your app > Battery > Power-intensive prompt [x] and Keep running after screen off [x]
  • Phone settings > Apps > Advanced (At the bottom) > Ignore optimisations > Press Allowed > All apps > Find your app on the list and set to Allow

Huawei P9 Plus

  • Phone settings > Apps > Settings > Special access > Ignore battery optimisation > select allow for your app.

Huawei P20, Huawei P20 Lite, Huawei Mate 10

  • Phone settings > Battery > App launch and then set your app to “Manage manually” and make sure everything is turned on. Also for reliable background processes you may need to uninstall PowerGenie as described above.

Huawei Honor 9 Lite, Huawei Mate 9 Pro

  • Phone settings > Battery > Launch and then set your app to “Manage manually” and make sure everything is turned on. On EMUI 4 there is no way out, sorry, but you can ask developers of your apps to implement the workaround described in Developer section

Xiaomi

Source: Don’t kill my app by Urbandroid

Explanation

Traditionally Xiaomi and their Android customization called MIUI belongs to the most troubled on the market with respect to non-standard background process limitations and non-standard permissions. There are no APIs and no documentation for those extensions. In default settings background processing simply does not work right and apps using them will break.

NOTE: Android One devices by Xiaomi work much better than MIUI-based devices. So if you like Xiaomi we definitely recommend to look for their Android One offering.

Solution

MIUI 10

To let your app run successfully in the background, make sure your settings look like the following (here for example is Sleep as Android):

Power management

Please enable:

  • Settings > Advanced Settings > Battery manager > Power plan is set to Performance
  • Device Settings > Advanced Settings > Battery Manager > Protected apps – your app needs to be Protected
  • Device Settings > Apps > your app > Battery > Power-intensive prompt and Keep running after screen off
  • Settings > Additional Settings > Battery & Performance > Manage apps’ battery usage and here:
    1. Switch Power Saving Modes to Off
    2. Choose the next options: Saving Power in The Background > Choose apps > select your app > Background Settings > No restrictions

App battery saver

Security > Battery > App Battery Saver > your app > No restriction

Autostart

(according to Xiaomi:

Open Security app > Permissions > Auto-start

Enable Autostart for desired apps.

Search for Your app and tap to enable

App pinning

When you open recent apps tray, drag your app downwards – it will be locked. So even if you clear recent apps it will not clear from the background. Drag downwards again to clear your app from the background.

OnePlus

Source: Don’t kill my app by Urbandroid

Explanation

OnePlus and their Oxygen OS Android modification is known as maximizing the stock Android experience. This may be true on the UX front but the exact opposite is valid for background process limits.

When releasing their 1+5 and 1+6 phones, OnePlus introduced one of the most severe background limits on the market to date, dwarfing even those performed by Xiaomi or Huawei. Not only did users need to enable extra settings to make their apps work properly, but those settings even get reset with firmware update so that apps break again and users are required to re-enable those settings on a regular basis.

Solution

Turn off System Settings > Apps > Gear Icon > Special Access > Battery Optimization.

WARNING: Recently OnePlus phones started reverting this setting randomly for random apps. So if you set it to be not optimized, the next day it may be back to optimized. There is no workaround and you may have to check system settings every once in a while.
See a bug report filed to OnePlus.
To avoid the system to automatically revert the not optimized setting, you must also lock the app into the ‘Recent App’ list. (solution described here)
Start the app you want to ‘Protect’. Press the phone Recent app button. Toggle the Lock button on the upper right corner of the app. This will avoid the app to be killed in background and the Battery optimisation setting to be reverted.

On some OnePlus phones there is also a thing called App Auto-Launch which essentially prevents apps from working in the background. Please disable it for your app.

Also try: Phone settings > Battery > Battery optimization and switch to the All apps list (Top menu) > Your app > Don’t optimize

NOTE: Some of our users indicated that you need to disable Doze mode in Developer options in 1+3 and earlier.

Also disable Settings > Battery > Battery optimization > (three dots) > Enhanced optimization. This option may also be called Advanced optimisation (OnePlus 6).

NOTE: This solves the problem where you lose Bluetooth connection to your smartwatch / fitness tracker (e.g. for sleep tracking).

Recent app clear behaviour manager is also a likely culprit:

Meizu

Source: Don’t kill my app by Urbandroid

Explanation

Meizu is probably on par with Huawei and Xiaomi in their approach to background process limitations, but they get a better rank probably just because those devices are not that common on the market and thus do not cause such a pain to the developers as the aforementioned.

Solution

Adjust your settings:

  • Device Settings > Advanced Settings > Battery manager > Power plan set to Performance
  • Device Settings > Advanced Settings > Battery Manager > Protected apps – check your app as Protected
  • Enable Device Settings > Apps > your app > Battery > Power-intensive prompt and Keep running after screen off

Asus

Source: Don’t kill my app by Urbandroid

Explanation

We are still collection feedback on Asus device so the following may not be a exhaustive list of issues.

On Asus devices there seems to be an optimization app called Power Master pre-installed with some modifications made by default, eg. blocking apps from starting and killing background tasks when your screen turns off.

However, if you know how, you can easily disable these. “ user_solution: “ The evil app on Asus is called Power Master. See the screens below. To make sure apps background processing works please make sure the following is set properly.

Power Manager > Mobile Manager > Settings > Uncheck: Clean up in suspend and Auto-deny apps from auto starting. See below for screenshots.

Solution

Wiko

Source: Don’t kill my app by Urbandroid

Explanation

We are still collecting feedback on Wiko devices so the following may not be a exhaustive list of issues. But Wiko devices are definitely problematic in terms of non-standard background process optimizations and adjustments to the settings that need to be done to make apps work properly.

Solution

  • Go to Phone Assistant / Manager > Battery > turn off Eco Mode.
  • Go back and go to Manual mode
  • Tap on the Gear icon on top right > Background apps whitelist > Now select Your app
1. Start Phone assist
and tap Tap Power Saver
2. Turn Eco. Mode OFF
and tap Optimized mode
3. Disable optimized mode
or make sure Your app is not optimized
4. Go to advanced settings
5. Get to the
background process whitelist
6. Make sure Your app
is on the list

Alternatively:

Go to dialer and put the code *#*#86569726#*#* and uncheck Lowram Enable And Background enable.
NOTE: this needs to be done again after reboot.

Oppo

Source: Don’t kill my app by Urbandroid

Explanation

We have currently only information for Oppo F1S, but on other models the situation may well be similar.

Solution

Oppo F1S

Background services are being killed (including accessibility services, which then need re-enabling) every time you turn the screen off. So far, a workaround for this is:

  • pin your app to the recent apps screen
  • enable your app in the app list inside the security app’s “startup manager” and “floating app list” (com.coloros.safecenter / com.coloros.safecenter.permission.Permission)
  • turn off battery optimizations
  • give the service a persistent notification to remain in the foreground

All four of those need to be done before the app would function. Here are links to some other resources verifying that some of the above steps work on other Oppo devices:

Lenovo

Source: Don’t kill my app by Urbandroid

Explanation

We’re still gathering more information on battery saving features on Lenovo phones.

Solution

Lenovo P2

Lenovo P2 has a very good battery life, but at a cost.

For an app to work in the background:

  • enable the padlock icon at an app in the right top corner in the overview of running apps. It’s only then actually running as a foreground process. If you swipe it away, its background process will be killed mercilessly.

It does not matter if the battery/power optimization is on or off in Settings -> Apps -> Your app -> Battery.

Sony

Source: Don’t kill my app by Urbandroid

Explanation

Sony gets a high rank in our listing of toxic Android vendors as historically it was Sony who introduced the first very effective non-standard background process optimization and opened the Pandora’s box.

It is called Stamina mode and it instantly breaks all background processes and all alarms if enabled.

Solution

Never use Stamina mode if you want your phone to do something useful when you are not actively using it.

Try to make your app not battery optimized in Phone settings > Battery > Three dots in the top right corner > Battery optimisation > Apps > your app.

Nokia

Source: Don’t kill my app by Urbandroid

Explanation

8/2019 update

GOOD NEWS: HMD Global claims to disable Evenwell powersaving apps on all devices running Android Pie or newer.
NOT SO GOOD NEWS: DuraSpeed remains.

HMD Global/Nokia was the main reason this website came to exist. They had the most aggressive app killers preinstalled on their phones.

There were three different app killing mechanisms:

  • com.evenwell.powersaving.g3 on Android Pie for most Nokia phones - this one has been disabled since 8/2019 on devices running Pie or greater
  • com.evenwell.emm on Android Go (Oreo?) for Nokia 1 - probably still in the wild since HMD only disabled Evenwell apps for Pie or greater
  • DuraSpeed on Android Pie (build 00WW_3_180) for the US Nokia 3.1 (TA-1049, TA-1063) and Nokia 5.1 - this one is still in the wild

Most Nokia phones (Power saver AKA com.evenwell.powersaving.g3)

The Evenwell Power saver *(com.evenwell.powersaving.g3)* has been disabled by HMD Global for devices running Pie or greater as of 8/2019.

The text below has been left here for a historical read.

Note: In Feb/March 2019, apparently on a few models distributed in Europe and US, the Evenwell Power Saver has been reworked to not kill the apps as aggressively, which largely resolves all issues for those models.

Nokia on Android O and P kills any background process including sleep tracking (or any other sport tracking) after 20 minutes if the screen is off. Also when killed all alarms are stopped which renders for example any alarm clock apps useless.

We have investigated this issue in details. We did even purchase a Nokia 6.1 to be able to reproduce the issue. The problem only occurs on Nokia devices with Android Pie. Nokia started to bundle a toxic app (package: com.evenwell.powersaving.g3 or com.evenwell.emm, name: Power saver) with their devices by some 3rd party company Evenwell. This app kills apps in the most brutal way we have seen so far among Android vendors.

Whitelisting apps from battery optimizations does not help! Evenwell kills even whitelisted apps.

What this non-standard app does is every process gets killed after 20 minutes regardless it is actually supposed to be running and doing a useful job for the user. Also alarms are not triggered. The aim is apparently to save your battery by rendering tracking apps and other apps that use background processing useless.

Moreover even 3rd party user visible alarms (alarm clock alarms) are not triggering properly on Nokia as foreground services cannot be started from background on Nokia. This is a serious issue unparalleled to any other vendor. We did not yet find a workaround for this :(. 3rd party alarms clock / calendars etc… won’t be realiable on Nokia.

You can read more on this issue here: https://community.phones.nokia.com/discussion/3428/background-service-killed-even-when-whitelisted

For fun investigative read about Evenwell, check out Who is Nokia?

Nokia 1 (com.evenwell.emm)

On Nokia 1 there is an alternative package that works very similar to what the com.evenwell.powersaving.g3 package is doing on the higher end models.

Nokia 3.1 and 5.1 (DuraSpeed)

HMD Global included Mediatek’s DuraSpeed task killer as a system service. Since DuraSpeed is not packaged as an app, it cannot simply be uninstalled, but it does have a secret settings switch that will enable or disable the service.

Solution

Most Nokia phones (Power saver AKA com.evenwell.powersaving.g3)

To fix this issue, please do the following:

  • Go to Phone settings > Apps > See all apps.
  • Tap on the right top corner menu > Show system.
  • Find Power saver app in the list, select it and Force close. It will remain stopped for a while, but will restart itself eventually.

From now on, background apps should work normally and use the standard Android battery optimizations.

Still 3rd party alarm clocks or any task scheduling of foreground tasks at a particular time won’t work. We do not have any solution for this at the moment UPDATE: in our preliminary tests it seems that force stopping or uninstalling the Power saver app also fixes alarms and starting of foreground services, until the Power saver restarts.

Alternative solution for tech-savvy users:

Most Nokia models

The Evenwell Power saver *(com.evenwell.powersaving.g3)* has been disabled by HMD Global for devices running Pie or greater as of 8/2019.

Disable the com.evenwell.powersaving.g3 package via the following adb commands:

adb shell
pm disable-user com.evenwell.powersaving.g3

Nokia 1 (Android Go)

Disable the com.evenwell.emm package via the following adb commands:

adb shell
pm disable-user com.evenwell.emm

Nokia 3.1 and 5.1

DuraSpeed is not packaged as an app, it cannot simply be uninstalled, but it does have a secret settings switch that will enable or disable the service. The flag is not exposed in the Settings app; it can only be manipulated through adb.

adb shell settings put global setting.duraspeed.enabled 0

Toggling it will produce immediate logcat feedback.

04-15 21:13:57.544 1063 1089 D DuraSpeed/DuraSpeedService: onChange, checked: false

Background apps and notifications should be now running without any restrictions - even after a factory reset and enabling all of HMD’s evenwell apps (including com.evenwell.powersaving.g3).

Nokia

Source: Don’t kill my app by Urbandroid

Explanation

8/2019 update

GOOD NEWS: HMD Global claims to disable Evenwell powersaving apps on all devices running Android Pie or newer.
NOT SO GOOD NEWS: DuraSpeed remains.

HMD Global/Nokia was the main reason this website came to exist. They had the most aggressive app killers preinstalled on their phones.

There were three different app killing mechanisms:

  • com.evenwell.powersaving.g3 on Android Pie for most Nokia phones - this one has been disabled since 8/2019 on devices running Pie or greater
  • com.evenwell.emm on Android Go (Oreo?) for Nokia 1 - probably still in the wild since HMD only disabled Evenwell apps for Pie or greater
  • DuraSpeed on Android Pie (build 00WW_3_180) for the US Nokia 3.1 (TA-1049, TA-1063) and Nokia 5.1 - this one is still in the wild

Most Nokia phones (Power saver AKA com.evenwell.powersaving.g3)

The Evenwell Power saver *(com.evenwell.powersaving.g3)* has been disabled by HMD Global for devices running Pie or greater as of 8/2019.

The text below has been left here for a historical read.

Note: In Feb/March 2019, apparently on a few models distributed in Europe and US, the Evenwell Power Saver has been reworked to not kill the apps as aggressively, which largely resolves all issues for those models.

Nokia on Android O and P kills any background process including sleep tracking (or any other sport tracking) after 20 minutes if the screen is off. Also when killed all alarms are stopped which renders for example any alarm clock apps useless.

We have investigated this issue in details. We did even purchase a Nokia 6.1 to be able to reproduce the issue. The problem only occurs on Nokia devices with Android Pie. Nokia started to bundle a toxic app (package: com.evenwell.powersaving.g3 or com.evenwell.emm, name: Power saver) with their devices by some 3rd party company Evenwell. This app kills apps in the most brutal way we have seen so far among Android vendors.

Whitelisting apps from battery optimizations does not help! Evenwell kills even whitelisted apps.

What this non-standard app does is every process gets killed after 20 minutes regardless it is actually supposed to be running and doing a useful job for the user. Also alarms are not triggered. The aim is apparently to save your battery by rendering tracking apps and other apps that use background processing useless.

Moreover even 3rd party user visible alarms (alarm clock alarms) are not triggering properly on Nokia as foreground services cannot be started from background on Nokia. This is a serious issue unparalleled to any other vendor. We did not yet find a workaround for this :(. 3rd party alarms clock / calendars etc… won’t be realiable on Nokia.

You can read more on this issue here: https://community.phones.nokia.com/discussion/3428/background-service-killed-even-when-whitelisted

For fun investigative read about Evenwell, check out Who is Nokia?

Nokia 1 (com.evenwell.emm)

On Nokia 1 there is an alternative package that works very similar to what the com.evenwell.powersaving.g3 package is doing on the higher end models.

Nokia 3.1 and 5.1 (DuraSpeed)

HMD Global included Mediatek’s DuraSpeed task killer as a system service. Since DuraSpeed is not packaged as an app, it cannot simply be uninstalled, but it does have a secret settings switch that will enable or disable the service.

Solution

Most Nokia phones (Power saver AKA com.evenwell.powersaving.g3)

To fix this issue, please do the following:

  • Go to Phone settings > Apps > See all apps.
  • Tap on the right top corner menu > Show system.
  • Find Power saver app in the list, select it and Force close. It will remain stopped for a while, but will restart itself eventually.

From now on, background apps should work normally and use the standard Android battery optimizations.

Still 3rd party alarm clocks or any task scheduling of foreground tasks at a particular time won’t work. We do not have any solution for this at the moment UPDATE: in our preliminary tests it seems that force stopping or uninstalling the Power saver app also fixes alarms and starting of foreground services, until the Power saver restarts.

Alternative solution for tech-savvy users:

Most Nokia models

The Evenwell Power saver *(com.evenwell.powersaving.g3)* has been disabled by HMD Global for devices running Pie or greater as of 8/2019.

Disable the com.evenwell.powersaving.g3 package via the following adb commands:

adb shell
pm disable-user com.evenwell.powersaving.g3

Nokia 1 (Android Go)

Disable the com.evenwell.emm package via the following adb commands:

adb shell
pm disable-user com.evenwell.emm

Nokia 3.1 and 5.1

DuraSpeed is not packaged as an app, it cannot simply be uninstalled, but it does have a secret settings switch that will enable or disable the service. The flag is not exposed in the Settings app; it can only be manipulated through adb.

adb shell settings put global setting.duraspeed.enabled 0

Toggling it will produce immediate logcat feedback.

04-15 21:13:57.544 1063 1089 D DuraSpeed/DuraSpeedService: onChange, checked: false

Background apps and notifications should be now running without any restrictions - even after a factory reset and enabling all of HMD’s evenwell apps (including com.evenwell.powersaving.g3).

AOSP (Pixel, Nexus...)

Source: Don’t kill my app by Urbandroid

Explanation

We are giving AOSP or stock Android a zero negative score. Even if it’s not perfect and you can still expect issues with background processing (see below) on devices with Android 6+, it is still the best we have :(. The truth is, if OEMs would stop adding battery saving features on top of AOSP, Android would be a much better place for users and app developers.

So even stock Android may kill your app when doing tasks valuable to the user. Especially if users enable Background restrictions for a particular app.

Moreover, in Android 6.0 Google did dramatically restrict background processing with their Doze mode https://developer.android.com/training/monitoring-device-state/doze-standby.

This attempt to unify various battery saving features across the Android ecosystem fell flat. It wasn’t only that Doze mode did not keep various vendors from implementing their own battery saving. Doze mode made some background processing scenarios impossible on Android or paradoxically more battery consuming e.g. gathering sensor data through sensor batching (see Solution for developers).

A serious bug in doze mode in Android 6.0 even prevented foreground services to do their job (see Solution for devs for workaround), but luckily this was fixed in 7.0.

Solution

Android P

There’s a special option in Settings > Apps > Your app > Advanced > Battery > Background restrictions. If users accidentally enable this option it will break their apps. And users do enable that option!

Pie and pre-Pie

If you see background processing issues, overall it is a good idea to make your app not battery optimized to ensure it gets the freedom it needs to perform in the background.

For that:

  1. Go to Settings > Apps > Your app > Advanced > Battery > Battery optimization
  2. Change view to All apps
  3. Search for your app
  4. Choose Not optimized

Android O

Make sure Settings > Apps > Your app > Advanced > Battery > Background limitations is not enabled. If the app is not yet optimized for Oreo API level it will break their background processing.

If all fails

If all fails you can turn doze mode completely off in Settings > Developer options. (If you don’t know how to enable developer options, Google should help.)

HTC

Source: Don’t kill my app by Urbandroid

Explanation

When you have connections such as Wi‍-Fi on while the phone is in sleep mode, some apps may still continue to use the battery. Starting from Android 6.0, battery optimization is enabled for all apps by default which helps prolong battery standby time when you’re not using the phone. The phone needs to be sitting idle for an extended period of time before battery optimization takes effect.

Solution

If there are apps that you don’t want battery optimization enabled, you can turn the feature off in those apps.

  • Open up Phone Settings.
  • Tap Power.
  • Tap Battery optimization.
  • Tap Not optimized > All apps to see the complete list of apps.
  • To turn off battery optimization in an app, tap the app name, and then tap Don’t optimize > Done. Repeat this process to turn off optimization in other apps. To filter the list and see which apps have battery optimization disabled, tap All apps > Not optimized.

AOSP (Pixel, Nexus...)

Source: Don’t kill my app by Urbandroid

Explanation

We are giving AOSP or stock Android a zero negative score. Even if it’s not perfect and you can still expect issues with background processing (see below) on devices with Android 6+, it is still the best we have :(. The truth is, if OEMs would stop adding battery saving features on top of AOSP, Android would be a much better place for users and app developers.

So even stock Android may kill your app when doing tasks valuable to the user. Especially if users enable Background restrictions for a particular app.

Moreover, in Android 6.0 Google did dramatically restrict background processing with their Doze mode https://developer.android.com/training/monitoring-device-state/doze-standby.

This attempt to unify various battery saving features across the Android ecosystem fell flat. It wasn’t only that Doze mode did not keep various vendors from implementing their own battery saving. Doze mode made some background processing scenarios impossible on Android or paradoxically more battery consuming e.g. gathering sensor data through sensor batching (see Solution for developers).

A serious bug in doze mode in Android 6.0 even prevented foreground services to do their job (see Solution for devs for workaround), but luckily this was fixed in 7.0.

Solution

Android P

There’s a special option in Settings > Apps > Your app > Advanced > Battery > Background restrictions. If users accidentally enable this option it will break their apps. And users do enable that option!

Pie and pre-Pie

If you see background processing issues, overall it is a good idea to make your app not battery optimized to ensure it gets the freedom it needs to perform in the background.

For that:

  1. Go to Settings > Apps > Your app > Advanced > Battery > Battery optimization
  2. Change view to All apps
  3. Search for your app
  4. Choose Not optimized

Android O

Make sure Settings > Apps > Your app > Advanced > Battery > Background limitations is not enabled. If the app is not yet optimized for Oreo API level it will break their background processing.

If all fails

If all fails you can turn doze mode completely off in Settings > Developer options. (If you don’t know how to enable developer options, Google should help.)

Other vendors

Source: Don’t kill my app by Urbandroid

Explanation

Whatever device you are using, don’t blame the developers as the first thing when something goes wrong. First check your phone settings whether some background processing is not restricted on your device.

See below for general solutions that apply for various vendors.

Solution

Look for any vendor-specific battery saver on your device and ideally uninstall if possible, disable if possible.

If not, you are left with the option to root your device or uninstall it though adb (requires some expert skills though):

adb shell

pm uninstall --user 0 com.useless.piece.of.trash

Look through the vendor-specific phone settings and search for anything related to battery optimization or background processing. If you find it try to disable it.

Android 6+

Always check the following setting Phone settings > Battery & power saving > Battery usage > Ignore optimizations > Turn on to ignore battery optimization for your app.

Android 8+

Check if Phone settings > Apps & Notifications > Your app > Background restrictions or Background limits are not enabled for the app.

If all fails you can turn Doze mode off completely.

Turn off doze on Android 6.0 and earlier

In Settings > Developer options. (If you don’t know how to enable developer options, Google should help.)

Turn off doze on Android 7+

Requires expert skills

dumpsys deviceidle disable

Smartwatches and other integrations

The process killing is especially problematic with smartwatches, which need their services to be run at all times.

Garmin

Please whitelist the following apps from any battery optimizations:

  • Garmin Connect
  • Sleep Garmin

Make sure to also follow specific steps for your phone manufacturer above.

Samsung Gear

Please whitelist the following apps from any battery optimizations:

  • Galaxy Wearable (formerly Samsung Gear Manager)
  • Gear plugin (specific for your watch model)
  • Sleep as Android Gear Companion
  • Samsung Accessory Service

Make sure to also follow specific steps for your phone manufacturer above.