I would like to exclude my app from the recent apps list (long press home, multitasking button, etc) BUT only for Android 4.4.1 and 4.4.2. The reason being is that on these Android versions, services can't restart themselves and my service is killed when my app is swiped away from the recents list. Normally it restarts itself without a problem, but it can't do so on 4.4.1 and 4.4.2.
I know you can add android:excludeFromRecents="true" in the manifest but that will exclude it on all Android versions.
I tried what was suggested here but can't get it to work:
Remove app from recent apps programmatically
Any ideas?
To exclude yourself from the recent-tasks list on 4.4 (not only 4.4.2):
Step #1: Create res/values/bools.xml
with a bool
resource, named is_44
, set to false
Step #2: Create res/values-v19/bools.xml
with a bool
resource, named is_44
, set to true
Step #3: Create res/values-v21/bools.xml
with a bool
, named is_44
, set to false
Step #4: Use android:excludeFromRecents="@bool/is_44"
in your <activity>
So, for API Level 19 and 20, you will be excluded from recents, but not other API levels.