[go: up one dir, main page]

Xiaomi

Story

Traditionally, Xiaomi and their Android customization called MIUI belongs in the most troubled group 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 looking for their Android One offering. “

Solution for users

App pinning / App locking

When you open the recent apps tray, drag your app downwards (it will be locked). Locked/pinned apps will gain further protection and not be cleared from the background, even if you clear recent apps. Drag downwards again to clear your app from the background.
On some phones, you need to long-press Your app and then choose the padlock icon from the menu:

Another method of app locking is hidden a little deeper:

Open Security app → Boost speed
Open the Settings cog icon
Go to Lock apps and pick your app

Autostart permission

On MIUI 14, there is a new permission to start from the background for each app, in Settings > Apps > Your app > App permissions > Background autostart.

Boost speed

If the app is locked here in this “Boost speed” feature, it may be spared by Ultra battery saver.

MIUI Optimizations

MIUI Optimizations were reported on MIUI 12 so far, but this option may be present on older versions too (let us know, if you have found this option on your phone). It is hidden in the Developers settings, so you need to switch to developer mode first (10x tap on MIUI version in About phone). As with all “optimizations”, the MIUI optimizations can break the background tasks.

There were some reports, that the MIUI optimization was missing in the menu - here is a workaround guide.

MIUI 12

To let your app run in the background, make sure settings for your app look like the following:

Some options might be missing for your app
(depends on the permissions the app needs).

MIUI 11

To let your app run in the background, make sure settings for your app look like the following:

MIUI 10

To let your app run 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

Hidden settings

On some XiaoMi phones, several settings options are hidden from you. Luckily, there are several apps on Play Store designed specifically for revealing these secret options and menus.

Solution for devs

Check Autostart permission

There is a way to check if the Autostart has been enabled,
https://github.com/XomaDev/MIUI-autostart

This has been tested on devices:

- MIUI 10 (firebase)
- MIUI 11 (physical device 11.0.9)
- MIUI 12 (physical device 12.5)
- MIUI 13 (untested, but work)
- MIUI 14 (physical device 14.0.2)

Usage

// make sure device is MIUI device, else an 
// exception will be thrown at initialization
Autostart autostart = new Autostart(applicationContext);

State state = autostart.getAutoStartState();

if (state == State.DISABLED) {
    // now we are sure that autostart is disabled
    // ask user to enable it manually in the settings app    
} else if (state == State.ENABLED) {
    // now we are also sure that autostart is enabled
}

Badge

Copy embed code to clipboard