Customize Android App Screen Image which is visibl

2019-02-19 19:13发布

问题:

I'm wondering how to customize the Image for My App to Home Screen image when My app is in background mode, that is when user navigates between Apps in recent apps option where a small screen shot for all running apps is visible.

Eg: Image Attached for more clarity.

回答1:

See the following questions:

  • Is there a way to change the thumbnail of an app in the android task switcher (long press on home button)
  • How to force app to create thumbnail (snapshot) for recent apps list?
  • How do I prevent Android taking a screenshot when my app goes to the background?

So theoretically there are two potential solutions:

  1. Override Activity.onCreateThumbnail() to customize the thumbnail.
  2. Add FLAG_SECURE to the window to prevent thumbnails (and screenshots).

Activity.onCreateThumbnail() sounds awesome until you realize it's been broken since Android 4.0.3 when the method call was commented out. See above posts or be direct, see the Android source code:

// First create a thumbnail for the activity...
// For now, don't create the thumbnail here; we are
// doing that by doing a screen snapshot.
info.thumbnail = null; //createThumbnailBitmap(r);

Currently, there is no easy way to customize the thumbnail.

So that really only leaves FLAG_SECURE. This doesn't allow you to customize the thumbnail, but rather prevents it, e.g. password forms and sensitive information. There's a downside to using the flag- it will also prevent screenshots, screen capture, and mirrored displays.