我正试图从另一个应用程序中杀死另一个android进程(app)。但我无法这样做..
private boolean isReaderAppRunning() {
ActivityManager activityManager = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
boolean isFound = false;
for(int i = 0; i < procInfos.size(); i++){
Log.e("SSSSSSS NAMEEEEE", procInfos.get(i).processName);
if(procInfos.get(i).processName.equals("com.bosch.bst_acp")) {
int pid = android.os.Process.getUidForName("com.bosch.bst_acp");
android.os.Process.killProcess(pid);
activityManager.killBackgroundProcesses("com.bosch.bst_acp");
isFound = true;
}
}
return isFound;
}
即使添加了权限,我也将pid设为-1。谁能告诉我我做错了什么?
<uses-permission android:name="android.permission.GET_TASKS"></uses-permission>