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.

Nokia

Source: Don’t kill my app by Urbandroid

Explanation

It seems HMD Global finally found the killer app, but unfortunately it is killing other apps!

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: Battery protection) 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.

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

Solution

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 Battery protection app in the list, select it and Force close. It will remain stopped until the next restart. From now on, background apps should work normally and use the standard Android battery optimizations.

Alternative solution for tech-savvy users:

Nokia 1 (Android Go)

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

adb shell
pm uninstall --user 0 com.evenwell.emm

Other Nokia models

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

adb shell
pm uninstall --user 0 com.evenwell.powersaving.g3

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. OnePlus Settings 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.

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.

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.

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.

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.

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

Huawei

Source: Don’t kill my app by Urbandroid

Explanation

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. In default settings background processing simply does not work right and apps working in background will break.

Solution

Adjust your settings:

  • 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:

  • Phone settings > Battery > App launch and then set your app to “Manage manually” and make sure everything is turned on. Huawei Honor 9 Lite:
  • Phone settings > Battery > Launch and then set your app to “Manage manually” and make sure everything is turned on.

Samsung

Source: Don’t kill my app by Urbandroid

Explanation

Yes, even Samsung - a dominant vendor in the Android market - is using nasty battery saving technique which may kill background processes and render alarm clocks useless. See below for workarounds.

Solution

Galaxy S8 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.

Stock Android

Source: Don’t kill my app by Urbandroid

Explanation

Yes, even stock Android may kill your app when doing a task valuable to the user.

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 developers for workaround), but luckily this was fixed in 7.0.

Solution

Android P

There 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

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

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 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.

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 try to uninstall it though adb (requires some expert skills though):

adb shell

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

Look though 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.

Share