Android never call method onCreateThumbnail

点点圈 提交于 2019-12-13 20:22:13

问题


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?


回答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).



来源:https://stackoverflow.com/questions/48853975/android-never-call-method-oncreatethumbnail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!