前几天在研究怎么非root下杀掉别人的Android进程,在网上搜了下资料,基本上是说调用killPackageProcesses这个方法。自己也试了下,发现有些可以调用成功,有些则失败,有些不解,于是有了这边文章,不足之处望海涵。
killPackageProcesses源码解析
1、killPackageProcesses
public void killBackgroundProcesses(final String packageName) {
if (checkCallingPermission(android.Manifest.permission.KILL_BACKGROUND_PROCESSES)
!= PackageManager.PERMISSION_GRANTED &&
checkCallingPermission(android.Manifest.permission.RESTART_PACKAGES)
!= PackageManager.PERMISSION_GRANTED) {
String msg = "Permission Denial: killBackgroundProcesses() from pid="
+ Binder.getCallingPid()
+ ", uid=&