Some apps keep running in background after being closed. I can see them in the device maintenance (battery). I would like to close these apps programmatically (These apps are mine too, so I could modify them if needed).
I tried "killBackgroundProcesses", but it doesn't work. Actually, the app doesn't even show in the processes list when I execute "adb shell ps -A". I also tried to close these apps differently, but they randomly appear in the "apps that drain battery" list.
How can I close them programmatically from my Android app?
You can get background processes pid with this command :
adb shell ps -A |grep BackgroundProcessesName |awk "{print $1}
and kill it :
adb shell kill pid
in one line command :
adb shell kill $(adb shell ps -A |grep BackgroundProcessesName |awk "{print $1})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.