When excludeFromRecents attribute is false, my app runs normally, entering destroy() only when flicked up on Recents page.
When excludeFromRecents attribute is true, my app enters destroy() when an unopened app is opened: In detail:
-
An editor E is opened, but not visible; it’s present in the Recents page. GMail is closed and not on the Recents page.
-
My app is opened. It appears on the Recents page until stopped by pressing Home. Then it is no longer on the recents page.
-
I can go back and forth between my app and the editor E normally; my app is in the stopped state when using E. My app is not displayed in the Recents page. All as expected.
-
If I open GMail (or any other unopened app) my app enters destroy(). Restarting my app goes through the whole create() cycle.
While I can remove my app from the Recents page with excludeFromRecents=true (at least after hitting Home); opening any other app sets my app back to the unopened state. I don’t understand.
If my app is to act freely with other apps, opening them should not destroy my app.
1
I found a solution in:
Hide screen in ‘Recent Apps List’, but allow screenshots
Hide screen in ‘Recent Apps List’, but allow screenshots
It adds
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
to the onCreate() method.
I’d avoid excludeFromRecents attribute.