Search code examples
androidshelladb

How to use adb to stop app from running in background?


I'm trying to make some apps on my phone to NOT run in the background. I tried from https://stackoverflow.com/a/52707377/5884503:

lz@vm:~/Android/Sdk/platform-tools$ ./adb shell cmd appops set package:com.whatsapp RUN_IN_BACKGROUND ignore
Error: No UID for package:com.whatsapp in user 0

How can I make whatsapp (and others) to not run in the background?


Solution

  • Try Like This

    cmd appops set <package_name> RUN_IN_BACKGROUND ignore

    in your case

    adb shell cmd appops set com.whatsapp RUN_IN_BACKGROUND ignore