Android什么时候拍摄其最近的应用切换器屏幕截图? [英] When does Android take its recent apps switcher screenshot?

查看:107
本文介绍了Android什么时候拍摄其最近的应用切换器屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有私人信息的应用程序,并且不应在Android的最新应用程序切换器中显示真实的屏幕截图.我尝试了此解决方案的变体,方法是将内容视图设置为onPause函数中的ImageView,但是在内容视图更改为自定义图像之前,操作系统似乎需要截屏.

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 setting the content view to an ImageView inside the onPause function, but it seems that the operating system takes a screenshot before the content view is changed to the custom image.

我也知道将窗口的布局参数标志设置为安全,使屏幕截图完全变成白色,但我希望可以有一种自定义屏幕截图的方法.

I am also aware of setting the window's layout parameter flags to secure, making the screenshot completely white, but I'd hope that there would be a way to customize the screenshot.

因此,我想知道Android在什么时候为应用切换器(特别是在KitKat和Lollipop中)拍摄了该应用的屏幕截图.

So, I'm wondering at what point that Android takes a screenshot of the app for the app switcher (specifically in KitKat and Lollipop).

推荐答案

编辑

不再可以自定义系统用来在最近的应用程序中显示缩略图的屏幕截图.

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

旧答案

看看方法Activity.onCreateThumbnail-正是您要寻找的方法,它使您可以为最近的屏幕"绘制自己的缩略图.

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.

您将获得Canvas作为可以直接绘制(或根本不绘制)的参数之一.要点是必须从此方法返回true,这表明系统不会绘制缩略图本身.

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.

最简单的解决方案是:

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

或者如果您想绘制自己的Bitmap

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;
}

这篇关于Android什么时候拍摄其最近的应用切换器屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆