No KYC · Android in the cloud, on 24/7 · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Rent a phone

Guide · background apps · from developer.android.com, checked 16 November 2026

How do you keep an Android app running in the background?

Last updated: · 5 min read

Quick answer

How do you keep an Android app running in the background?

Keep the app in the foreground where you can, exempt it from battery optimization, and check its standby bucket with adb shell am get-standby-bucket. Android's Doze and App Standby rules hold back idle apps on every phone. A Droidkeep cloud phone removes the hardware side: it stays on 24/7 for the whole rental, from $2.97 for 30 days.

In brief
  • Doze: on a device unplugged, still and with the screen off, Android suspends network access, ignores wake locks and defers jobs and alarms.
  • App Standby Buckets (Android 9+): apps used less get fewer jobs and alarms; Android 12 adds a restricted bucket.
  • User fix: put the app on the battery optimization exemption list.
  • Developer fix: a foreground service for work the user expects to continue, setExactAndAllowWhileIdle() for critical alarms.

How do you keep an app running, step by step?

Five steps, from the Android documentation on Doze and App Standby. Replace PACKAGE with the app's package name, which adb shell pm list packages -3 shows.

  1. Leave the app in the foreground

    An app with an open activity is in the active bucket, the least limited one. On a phone kept for one app, simply leave it open.

  2. Exempt it from battery optimization

    Android's documentation names Settings > Battery > Battery Optimization. An exempted app can use the network and hold partial wake locks during Doze.

  3. Check its standby bucket

    Run adb shell am get-standby-bucket PACKAGE. A value above 10 (active) means Android is throttling it.

  4. Test it under Doze

    Run adb shell dumpsys deviceidle force-idle, wait, then adb shell dumpsys deviceidle unforce and adb shell dumpsys battery reset. Check the app recovered.

  5. Test it under App Standby

    Run adb shell dumpsys battery unplug and adb shell am set-inactive PACKAGE true, then am set-inactive PACKAGE false and am get-inactive PACKAGE.

Check and test background limits with adb
adb shell am get-standby-bucket PACKAGE

# Doze test
adb shell dumpsys deviceidle force-idle
adb shell dumpsys deviceidle unforce
adb shell dumpsys battery reset

# App Standby test
adb shell dumpsys battery unplug
adb shell am set-inactive PACKAGE true
adb shell am set-inactive PACKAGE false
adb shell am get-inactive PACKAGE

Which Android limit affects which kind of work?

Each mechanism hits different work, and each has its own way out. Summary of the Android developer documentation, read on 16 November 2026.

Android background limits from the Android documentation, what they hold back and how an app keeps working
LimitApplies fromWhat it holds backWay out
DozeAndroid 6.0Network, wake locks, jobs, syncs, standard alarmsExemption list; setExactAndAllowWhileIdle() for alarms
App StandbyAndroid 6.0Network and jobs of apps not used recentlyForeground use, a visible notification, the exemption list
Standby bucketsAndroid 9How often jobs and alarms runActive use; exempted apps skip bucket limits
Restricted bucketAndroid 12Jobs once a day in a 10-minute batch, one alarm a dayUse the app within 45 days on Android 12; "unrestricted" setting

What can you do if you did not build the app?

Keep it open, exempt it, and open it now and then. The exemption list is in Settings, as above. On Android 12 an app nobody interacts with for 45 days can fall into the restricted bucket; opening it resets that clock. Apps that the user marks as "unrestricted" in settings are exempt from the restricted bucket.

If the app still stops, it was not built to run unattended. Some apps stop on purpose to save data or to follow their own rules; many games do, as the idle games page explains. The 24/7 apps page covers which apps are worth running all day.

What should you do if you build the app?

Use the tool Android designed for each kind of work. For work the user expects to continue, such as playback or an upload, use a foreground service with its notification. For critical alarms, setAndAllowWhileIdle() or setExactAndAllowWhileIdle(), which fire at most once per 9 minutes per app in Doze. For messages, Firebase Cloud Messaging.

Android's guide warns against starting a foreground service only to avoid being judged idle. Google Play also forbids asking for a direct battery exemption unless Doze breaks the app's core function; task automation apps are one accepted case.

Why does a cloud phone help?

It removes the reasons a handset stops: unplugging, moving, sleeping screens and flat batteries. Doze starts when a device is unplugged, still and dark; a phone in your pocket meets those conditions every night. A Droidkeep phone has no battery to run down and nobody to switch it off. The phone keeps running 24 hours a day for the whole rental, whether or not a screen is open; apps stay where you left them.

Android's own rules still run inside it, so the steps above still apply. According to Droidkeep's survey of 16 November 2026, keeping a phone on all month with per-minute billing cost $302.40 at GeeLark's $0.007 a minute; a Droidkeep 4 GB phone costs $2.97 for 30 days. The ADB guide shows how to run the commands on it.

Background app questions

Do I need root to change these settings?

No. The exemption list is in Settings, and the adb shell commands above run without root.

Does the Doze test break anything?

No. unforce and battery reset return the phone to normal. Run them after each test.

Why does my app stop after a few hours anyway?

Low memory can also close background apps. Give the app more RAM by closing others, or use a larger phone size.

Does a foreground service keep the app alive?

It marks the app as in use, so App Standby does not treat it as idle. Android's guide says to use one only for work the user expects to continue.

Are task killers useful?

No. They close apps without choosing, which is the opposite of what a 24/7 app needs.

Verdict
  • Foreground, exempted, tested: those three steps keep most apps running on Android 12.
  • A phone that never sleeps does the rest: a Droidkeep phone stays on for the whole rental.
Sources (4)
  1. Optimize for Doze and App Standby — Android Developers (read 2026-11-16)
  2. App Standby Buckets — Android Developers (read 2026-11-16)
  3. Android Debug Bridge (adb) — Android Developers (read 2026-11-16)
  4. GeeLark pricing — GeeLark (read 2026-11-16)

A phone that never sleeps

Keep 4: on 24/7 for 30 days, $2.97.

From $0.08/day · no KYC

Rent a phone