Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not show app on recent apps list in ICS? excludeFromRecents doesn't work

I know it should be achievable be either android:excludeFromRecents="true" in android manifest or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS Intent flag.

Problem is, that doesn't work if application is currently being shown - when Recent Apps button is clicked, application is always shown in the first place, allowing for quick killing of the application (by swiping it). Not good for an alarm clock app.

Music Service keeps on playing fortunately and user can get back to finishing alarm by the notification, but I have really hard time recreating activities stack.

Any quick fix available?

like image 948
Koger Avatar asked May 10 '13 12:05

Koger


People also ask

How to remove an app from recent apps?

Large thumbnails of recently used apps display with each app's icon. To remove an app from the list, hold your finger down on the thumbnail for the app you want to remove until a popup menu displays. Touch “Remove from list” on that menu.

What is recent apps screen?

The Recents screen (also referred to as the Overview screen, recent task list, or recent apps) is a system-level UI that lists recently accessed activities and tasks. The user can navigate through the list and select a task to resume, or the user can remove a task from the list by swiping it away.


1 Answers

This is a well known Android Issue: https://code.google.com/archive/p/android-developer-preview/issues/1662

This is a solution:

ActivityManager am =(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
if(am != null) {
    List<ActivityManager.AppTask> tasks = am.getAppTasks();
    if (tasks != null && tasks.size() > 0) {
        tasks.get(0).setExcludeFromRecents(true);
    }
}

If Task Root Activity is excluded from recent, all activities in this task will be excluded too.

like image 166
StepanM Avatar answered Nov 04 '22 08:11

StepanM