我从应用程序中杀死第三方应用程序时出现问题。这是代码:
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appProcesses = activityManager
.getRunningAppProcesses();
for (RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
if (appProcess.pkgList[0].equalsIgnoreCase("com.adobe.air")) {
Log.v("ACTIVITY FOUND", "" + appProcess.pkgList[0]
+ " - " + appProcess.pid);
activityManager.killBackgroundProcesses("com.adobe.air");
activityManager.restartPackage("com.adobe.air");
android.os.Process.killProcess(appProcess.pid);
}
}
}
Log.v("RUN", "----------------------------------");
在AndroidManifest中,我添加了权限android.permission.KILL_BACKGROUND_PROCESSES
和android.permission.RESTART_PACKAGES
。
在日志中,我可以在com.adobe.air包运行时正确阅读该消息,但killBackgroundProcesses
,restartPackage
和KillProcess
没有成功关闭应用程序本身。怎么了?
答案 0 :(得分:0)