The app I'm working on shows some sensitive information that must not be shown on the "Recent Tasks" screen when stopping the app by pressing the home button.
I'd like to blur the sensitive data in the screenshot or show the app logo instead.
I am aware of the following approaches but they don't fit my requirements:
- Setting the actvitie's
android:excludeFromRecents
to true in the manifiest prevents the app from being shown at all in the recent tasks. This would disrupt the user experience. - Using
FLAG_SECURE
results in a blank card on the recents tasks screen. (How do I prevent Android taking a screenshot when my app goes to the background?) I don't like the blank screen. However, I'll stick to this solution if there is no workaround. - Overriding
onCreateThumbnail
seems like the ideal solution but, unfortunately, doesn't work as it's currently not invoked by the OS :( (https://code.google.com/p/android/issues/detail?id=29370)
And then there are some workarounds that I tried out but that didn't work as hoped:
- Start a new activity that shows the app logo in
onPause
so that it's screenshot is shown instead of the actual activitie's one. But the new activity takes too long to open and it disrupts the user experience. - Set the activitie's content view to an image of the app logo in
onPause
. That seemed like a great solution to me. Unfortunately, the screenshot for the recent tasks screen is taken at an unspecified time. During testing the app logo quickly appears before the app is closed when pressing 'Home' but the resulting screenshot shows the activity a short time before that. - Removing the sensitive data from the widgets (e.g.
textView.setText("")
) has the same problem of screenshot timing just mentioned.
Any alternative ideas or solutions to the listed workarounds?