4

My add displays private data, so I don't want it to be possible to see the app contents in the task switcher.

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274
Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • 1
    A quick guess, The task switcher only shows background tasks. Could you change the UI in onPause(), I guess before the super call, and restore it in onResume()? – Simon Nov 06 '12 at 22:33
  • 1
    Very similar question with a different answer: http://stackoverflow.com/questions/11848132/is-there-a-way-to-change-the-thumbnail-of-an-app-in-the-android-task-switcher-l – Vladimir Panteleev Jul 12 '14 at 17:23

1 Answers1

5

You can't control what it shows, but you can exclude it from appearing in Recent Apps altogether. In your manifest, add the following attribute to any activity tags for Activities that should not show in Recent Apps:

android:excludeFromRecents="true"

See also: <activity>

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274
  • 8
    Or, if you want to be in the recent tasks list, but simply do not want to have your app's thumbnail retained, use `FLAG_SECURE`: http://commonsware.com/blog/2012/01/16/secure-against-screenshots.html – CommonsWare Nov 06 '12 at 23:53
  • @CommonsWare Interesting, I didn't know that would prevent the system from displaying it. What displays in place of it? – Kevin Coppock Nov 07 '12 at 00:15
  • 1
    It works! The screenshot in the recent tasks list is all black. (That was meant to be @CommonsWare not Aha by the way!) – Timmmm Nov 07 '12 at 15:20
  • 2
    Yes, as @Timmmm notes, screenshots (whether recent tasks or the manual stuff you do on ICS+ devices) come out blank for "secure" windows. It's conceivable that all-black might get replaced by some other stock image in the future (e.g., bugdroid in police riot gear), but it should never be your app's screen contents. – CommonsWare Nov 07 '12 at 15:27
  • @CommonsWare: I have researched a lot but could not find how the Overview(or recent tasks) behave in Android 5.0 onwards. Can you tell me how recent task image is displayed now when FLAG_SECURE is set ? – r.bhardwaj Apr 14 '15 at 07:17