I know that this question was asked before here Android Disable Recent Task Button like in SureLock, but since the answer there is not working, maybe some can share some light on this forgotten mater.
I also tried:
private void closeRecents() {
activ.sendBroadcast(new Intent("com.android.systemui.recent.action.CLOSE"));
Intent closeRecents = new Intent("com.android.systemui.recent.action.TOGGLE_RECENTS");
closeRecents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
ComponentName recents = new ComponentName(SYSTEM_UI_PACKAGE_NAME, RECENTS_ACTIVITY);
closeRecents.setComponent(recents);
activ.startActivity(closeRecents);
}
but no luck
This answer helped me. It is not the best as some methods are now deprecated. It works for me (4.4.2), for now, but I too would like to find a more ideal solution.
With this permission: