When does Android take its recent apps switcher screenshot?

前端 未结 1 922
轮回少年
轮回少年 2020-12-06 04:41

I am developing an app that has private information and should not display a real screenshot in Android\'s recent app switcher. I\'ve tried a variation of this solution, by

相关标签:
1条回答
  • 2020-12-06 05:30

    EDIT

    It is no longer possible to customize the screenshot which system uses to present the thumbnail in the recent apps.

    Old answer

    Take a look at method Activity.onCreateThumbnail - this is exactly what you're looking for as it let you draw your own thumbnail for Recent screen.

    You get Canvas as one of the parameters in which you can draw (or not draw at all) directly. The main point is that you have to return true from this method, which indicates that system won't draw thumbnail itself.

    The simpliest solution would be:

    @Override
    public boolean onCreateThumbnail (Bitmap outBitmap, Canvas canvas) {
        // Do nothing or draw on Canvas
        return true;
    }
    

    or if you want to draw your own Bitmap

    @Override
    public boolean onCreateThumbnail (Bitmap outBitmap, Canvas canvas) {
        Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.myBitmap);
        canvas.drawBitmap(myBitmap, 0, 0, null);
    
        return true;
    }
    
    0 讨论(0)
提交回复
热议问题