I'm designing an application for removing recent tasks. and i use this code for remove recent tasks,
public boolean removeTask(int taskId, int flags) {
    try {
        return (Boolean) mRemoveTask.invoke(mActivityManager, Integer.valueOf(taskId), Integer.valueOf(flags) );
    } catch (Exception ex) {
        Log.i("MyActivityManager", "Task removal failed", ex);
    }
    return false;
}
public void clearRecentTasks() {
    List<ActivityManager.RecentTaskInfo> recents = mActivityManager.getRecentTasks(1000, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
    // Start from 1, since we don't want to kill ourselves!
    for( int i=1; i < recents.size(); i++ ) {
        removeTask( recents.get(i).persistentId, 0);
    }
}
