0

I did

./adb shell cmd appops set com.whatsapp RUN_IN_BACKGROUND ignore

for lots of apps in my android. However, when I go into the app settings, I still can press "force stop". Does that mean the app is still running in the background, even if I setted it to ignore?

How can I see the apps running? adb shell ps shows too much thing and I don't know which ones are the apps.

Also, will these settings work after reboot?

6
  • 1
    RUN_IN_BACKGROUND definitely works. Android relies on this AppOp for its internal functionality (Restricted Apps in Battery Manager settings). But RUN_IN_BACKGROUND doesn't guarantee that the app won't have its native process running. App's background activity is stopped within Java stack by Android's ActivityManagerService. That's what cached state of an app is. Apr 5 at 10:15
  • 1
    Force Stop button can be active even if app has no background activity going on and just its native process is alive: android.googlesource.com/platform/packages/apps/Settings/+/refs/…. So an active Force Stop button doesn't indicate that RUN_IN_BACKGROUND is not working. Apr 5 at 10:17
  • @IrfanLatif by native process do you mean native java or native C++? is it possible to stop the app from running its native process? I wanted for apps to not run at all unless I have them open
    – Gatonito
    Apr 5 at 23:24
  • By native I mean native to operating system. Native Linux process, not native to a language. // It's not the app which runs its native process. Android's zygote forks apps' virtual machines, ActivityManager service allocates the app resources (by making use of Linux cgroups and other subsystems), controls their activity (through manifest permissions), and may keep them in cached or background state even when the apps are completely idle. Or may kill them if resources (RAM in particular) are needed. If you want to change this behavior you need to modify the Android framework. Apr 6 at 1:19
  • @IrfanLatif how does apps start to run again after I force closed them, even if I didn't open them again?
    – Gatonito
    Apr 17 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.