Why Android keeps killing the app while you are still using it

A session that works for two minutes and then dies with no error is almost never a bug in the app. It is Android deciding the app should stop, and on some manufacturers that decision is far more aggressive than anything Google ships.

Updated:

Three separate systems, often blamed as one

Doze. When the phone has been stationary, unplugged and screen-off for a while, Android batches network access and defers background work. It is the mildest of the three and it mostly affects a phone nobody is holding.

App Standby buckets. Android sorts apps by how often you actually use them — active, working set, frequent, rare, restricted — and restricts background work accordingly. An app you installed for one support call sits in a low bucket and gets treated harshly.

Manufacturer battery managers. This is the one that actually causes the problem. Xiaomi, Huawei, Oppo, Vivo, Samsung and others layer their own killers on top of Android, and they are considerably more aggressive than stock. On some devices an app is stopped within minutes of leaving the foreground regardless of what Android itself would allow.

The one exemption that matters

An app doing continuous work you can see — capturing a screen, playing music, navigating — is supposed to run a foreground service, which is why you see a persistent notification while sharing. A foreground service is largely protected from Doze and standby.

It is not protected from the manufacturer layer. That layer will stop a foreground service too, and it will do it without telling you or the app. The persistent notification simply disappears.

Advertisement

What to change, in order of effect

  1. Turn off battery optimisation for the app. Settings → Apps → the app → Battery → Unrestricted. On many devices this alone fixes it.
  2. Lock the app in recents. On Xiaomi, Oppo and several others, open the app switcher and use the padlock on the app card. This is a manufacturer feature with no equivalent in stock Android, and on those devices it matters more than any Android setting.
  3. Turn off "adaptive battery" for it if the manufacturer exposes a per-app switch.
  4. Allow autostart. Xiaomi, Huawei, Oppo and Vivo have an autostart list that is off by default for everything. An app that is not on it cannot restart itself after being killed.
  5. Keep the screen on while sharing, or use the app's own keep-awake option if it has one. A screen that stays on is the strongest signal to the system that something is in use.
  6. Do not "clean" or swipe the app away. Swiping it out of recents is an explicit instruction to stop it, and cleaner apps do that on a schedule.

Telling this apart from a network problem

SymptomWhich layer
Dies about a minute after the screen goes offBattery manager or Doze
Dies right after switching to another appManufacturer killer — lock it in recents
Dies at random while actively in useMemory pressure — close other apps
Never connects at allNot this — see the pairing guide
Connects, then quality degrades but survivesNetwork, not background limits
Stops after a restart and does not come backAutostart not permitted

The trade-off, stated honestly

Everything above disables a battery-saving measure. On a phone doing screen capture that is the correct choice for the duration of a session, and the wrong choice as a permanent setting for an app you use once a month. The reasonable pattern is to exempt the app, use it, and not worry about it — the drain from an idle exempted app is small, while the drain from an active screen-sharing session is real and unavoidable. See what a session actually costs in battery and data.

More guides

Try Remote Phone

Share an Android screen, or control one from another phone or your computer's browser. No account needed.

Try Remote Phone