您好
如何使用我的应用中的代码杀死Android手机中的所有有效进程? 我阅读了几篇文章,如How to kill all running applications in android?,并尝试了这段代码:
List<ApplicationInfo> packages;
PackageManager pm;
pm = getPackageManager();
//get a list of installed apps.
packages = pm.getInstalledApplications(0);
ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
Log.d("Packages" , String.valueOf(packages));
for (ApplicationInfo packageInfo : packages) {
mActivityManager.killBackgroundProcesses(packageInfo.packageName);
Log.d("Cleaned" , String.valueOf(packageInfo.packageName));
}
Logcat确实显示了所有活动进程,但没有关闭/没有任何事情发生。
是的,我确实已将此包含在我的清单中:
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
我有什么东西我不在?