[英]How to kill background processes on Samsung devices programmatically
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.我试过“killBackgroundProcesses”,但它不起作用。 Actually, the app doesn't even show in the processes list when I execute "adb shell ps -A".
实际上,当我执行“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?如何从我的 Android 应用程序中以编程方式关闭它们?
You can get background processes pid with this command :您可以使用以下命令获取后台进程 pid:
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})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.