How not to show the application in the list of recent applications in ICS? excludeFromRecents not working

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

The problem is that this does not work if the application is currently displayed - when you click the "Recent Applications" button, the application is always displayed first, which allows you to quickly kill the application (by scrolling it). Not suitable for alarm app.

The music service continues to play, fortunately, and the user can return to the completion of the alarm with a notification, but it is very difficult for me to recreate the action stack.

Any quick fix available?

+5
source share
1 answer

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

This 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 the task "Main task" is excluded from recent times, all actions in this task will also be excluded.

+1
source

All Articles