I tried a code but not able to remove app from recent app menu
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)
am.killBackgroundProcesses("com.example.admin.personalassistant");
You need this two permissions
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.GET_TASKS" />
and then declare the ActivityManager and a List for the processes:
ActivityManager am;
List<ActivityManager.RunningAppProcessInfo> processes;
Use ActivityManager to list all process
am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
and list all processes
processes = am.getRunningAppProcesses();
You can kill now all processes with a for-loop like this:
for (ActivityManager.RunningAppProcessInfo processInfo: processes) {
android.os.Process.killProcess(processInfo.pid);
android.os.Process.sendSignal(processInfo.pid, android.os.Process.SIGNAL_KILL);
amg.killBackgroundProcesses(processInfo.processName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.