TechBuzzPro

Stop Android App from Auto‑Closing

· 6 min read · Phones & Tablets

In this article
  1. What You'll Need
  2. Step‑By‑Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes—you can stop an Android app from automatically shutting down by adjusting battery‑optimization settings, background‑activity permissions, and a few developer options.

What You'll Need

  • An Android smartphone or tablet running Android 6.0 (Marshmallow) or newer.
  • The app that is unexpectedly closing.
  • Access to the device’s Settings menu.
  • (Optional) A computer with ADB installed if you need to grant special permissions.

Step‑By‑Step

  1. Identify the problematic app. Open the app and note the exact moment it closes—whether it happens after a period of inactivity, when you switch to another app, or immediately after launch. Knowing the pattern helps you choose the right setting to adjust.
  2. Disable battery optimisation for the app. Go to Settings > Battery > Battery optimisation. Tap the drop‑down that says “Not optimised” and select “All apps”. Find the app in the list, tap it, and choose Don’t optimise. On some devices the path may be Settings > Apps & notifications > Special app access > Battery optimisation. This tells Android not to put the app into Doze or App Standby, which are common reasons for forced shutdowns.
  3. Allow background activity. Still in Settings, navigate to and toggle on Allow background activity . If the toggle is missing, look for a “Background restriction” switch and ensure it is off.
  4. Check manufacturer‑specific memory‑cleaner settings. Many OEM skins (e.g., Xiaomi’s MIUI, Huawei’s EMUI, OnePlus’s OxygenOS) include aggressive task‑killers. Open the device’s own optimisation app (often called “Security”, “Battery & performance”, or “Device care”) and add the app to the whitelist or exempt it from “Auto‑clean” and “Power saver” features.
  5. Make sure the developer option “Don’t keep activities” is turned off. Enable Developer Options by tapping Settings > About phone > Build number seven times. Then go to Settings > System > Advanced > Developer options and verify that Don’t keep activities is unchecked. When enabled, Android destroys every activity as soon as you leave it, causing the exact behaviour you’re trying to avoid.
  6. Review the app’s internal settings. Some apps include a built‑in “Auto‑close” or “Sleep after inactivity” option. Open the app’s own settings menu (usually accessed via a three‑dot or hamburger icon) and disable any feature that explicitly shuts the app down after a timeout.
  7. Update the app and Android system. Out‑of‑date software can contain bugs that trigger unexpected termination. Open the Play Store, tap your profile picture, select Manage apps & device, and update the app. Then go to Settings > System > System update and install any pending Android updates.
  8. Clear the app’s cache. Corrupted cache data sometimes forces the OS to kill the process. Go to and tap Clear cache . Do not tap “Clear storage” unless you are prepared to lose local data.
  9. Restart the device. A simple reboot flushes temporary system resources and can resolve lingering background‑task conflicts that cause abrupt shutdowns.
  10. Use ADB to grant the IGNORE_BATTERY_OPTIMIZATIONS permission (optional). Connect the device to a computer with USB debugging enabled (found under Developer options). Open a terminal and run:
    adb shell pm grant com.example.app android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
    Replace com.example.app with the app’s package name. This forces Android to treat the app as exempt from all battery‑saving measures.
  11. Turn off system‑wide power‑saving mode. If you have enabled a low‑power mode, Android may aggressively close background apps. Disable it via Settings > Battery > Power saver.
  12. Test the app. Open the app again and perform the actions that previously caused it to close. If it stays alive, the problem is solved. If it still shuts down, move on to the troubleshooting section.

Common Mistakes

  • Disabling battery optimisation for the wrong app – always double‑check the package name before confirming.
  • Enabling the developer option “Don’t keep activities” instead of disabling it – this single toggle is a frequent cause of immediate app termination.
  • Clearing the app’s storage instead of just the cache – you may lose login credentials, saved preferences, or offline data.
  • Using a third‑party task‑killer app while also tweaking system settings – these external killers can override your whitelist changes.
  • Assuming the setting is permanent after a reboot – some OEMs reset optimisation whitelists after a system update, so re‑check after major updates.

Tips

  • Enable Adaptive Battery exceptions: Android 9+ groups apps by usage patterns. Adding your app to the “Never sleeping apps” list (found under Settings > Battery > Adaptive Battery > Never sleeping apps) helps keep it alive.
  • If your device has a “Lock app in memory” feature (common on Samsung and OnePlus), turn it on for the app to prevent the system from reclaiming its RAM.
  • Use the built‑in Screen pinning feature (Settings > Security > Screen pinning) when you need the app to stay foreground for an extended period, such as during a presentation.
  • When testing, keep the screen on via Settings > Display > Stay awake (developer option) to rule out screen‑off power‑saving as the cause.
  • Document the package name of the app (found in Play Store URL or via adb shell pm list packages | grep ) so you can quickly apply ADB commands if needed.

Troubleshooting

If the app continues to close after following the steps above, follow this escalation path:

  1. Verify that no other app is interfering. Disable any third‑party battery‑saver or task‑killer apps temporarily and test again.
  2. Check for system‑level restrictions. Some carriers or enterprise‑managed devices enforce policies that force apps to stop. Look under Settings > Security > Device admin apps for any management profiles.
  3. Reinstall the app. Uninstall, then reinstall from the Google Play Store. This clears hidden configuration files that may be causing crashes.
  4. Reset app preferences. Go to Settings > Apps & notifications > See all apps > Menu (three dots) > Reset app preferences. This restores default permissions without deleting app data.
  5. Factory reset as a last resort. If the problem persists across multiple apps, a full device reset may be necessary. Back up your data first; a reset will erase all user data.

Frequently Asked Questions

Why does Android close apps on its own?

Android manages RAM and battery life by moving idle apps to a stopped state. When memory is low or the system enters Doze mode, it may terminate background processes to keep the device responsive.

Can I completely stop Android from killing any app?

No. The OS must reclaim resources at times, especially under low‑memory conditions. You can only whitelist specific apps to reduce the likelihood of termination.

How do I add an app to the battery‑optimisation whitelist?

Open Settings > Battery > Battery optimisation, change the view to “All apps”, select the desired app, and choose “Don’t optimise”. The exact wording may vary by manufacturer.

Does disabling “Don’t keep activities” affect battery life?

Leaving the option disabled (the default) actually improves battery life because Android can safely destroy activities that are no longer visible. Enabling it forces the system to keep every activity in memory, which can increase power consumption.

Will granting the IGNORE_BATTERY_OPTIMIZATIONS permission via ADB harm my device?

It does not harm the device, but the app will no longer be subject to Doze or App Standby, which may lead to higher battery drain if the app runs continuously in the background.

My device runs a custom ROM—do these steps still apply?

Most steps are generic to Android’s core settings, but custom ROMs may rename menus or relocate optimisation options. Look for similar terms such as “Battery saver”, “Background restrictions”, or “App power management”.