0

Based on Android documentation, method onCreateThumbnail is called before pausing the activity, and should draw into outBitmap the imagery for the desired thumbnail in the dimensions of that bitmap. It can use the given canvas, which is configured to draw into the bitmap, for rendering if desired.

The default implementation returns fails and does not draw a thumbnail; this will result in the platform creating its own thumbnail if needed.

When the method returns true, system will not use a standard thumbnail, but custom thumbnail drawn into the canvas is (or should be) used.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Window window = getWindow();
    // cleared by default, but let's make it explicit
    window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE); 
}

// @Override
public boolean onCreateThumbnail(Bitmap outBitmap, Canvas canvas) {
    Log.d(TAG, "onCreateThumbnail");
    return false;
}

However, it seems that the system never call this method. Is there some special settings or flag needed to have this method called and being able to generate own thumbnail for the activity?

Ωmega
  • 42,614
  • 34
  • 134
  • 203
  • I haven't looked into this in quite some time. The only thing that I recall that we have control over is the action bar equivalent that appears at the top of our app's card (plus `FLAG_SECURE`). – CommonsWare Feb 18 '18 at 20:55
  • From Activity documentation: "This method was deprecated in API level 28. Method doesn't do anything and will be removed in the future." – happydude Oct 11 '18 at 10:24

1 Answers1

1

It is not possible to customize the activity thumbnail which system uses in the recent apps preview.

The method onCreateThumbnail had been broken since Android 4.0.3, when its call was commented out (see the source code).

Ωmega
  • 42,614
  • 34
  • 134
  • 203