如何强制应用近期应用列表创建缩略图(快照)? [英] How to force app to create thumbnail (snapshot) for recent apps list?

查看:1344
本文介绍了如何强制应用近期应用列表创建缩略图(快照)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的测试报告:
在最近的应用列表中的应用程序的缩略图完全不调整在我看来无论是像一个主屏幕壁纸(tolikdru:大概,只是透明的矩形),或类似的应用程序屏幕的绿色背景,但从来没有作为一个真正的应用程序的快照。
因此,该行为是什么喜欢这里描述。

Tester of my app has reported: "The thumbnail of the app in the Recent apps list is not tuned at all. At me it appears either like a homescreen wallpapers (tolikdru: probably, just transparent rect), or like green background of the app screen, but never as a real snapshot of the app." So the behaviour is something like described here.

我的设备与Android 2.0,所以我不能检查和调试的问题(在最近使用的应用缩略图是由于Android 3.0+)。因此,进一步的研究是在一个盲模式。

My device is with Android 2.0 so I cannot check and debug the issue (thumbnails in Recent apps are since Android 3.0+). So further research was in a "blind mode".

我决定手动强制使用onCreateThumbnail()<一个应用程序缩略图的创建href=\"http://stackoverflow.com/questions/11848132/is-there-a-way-to-change-the-thumbnail-of-an-app-in-the-android-task-switcher-l\">as这里建议。 (为了简化任务开始的时候,我不明白真正的快照,而是采取了启动画面绘制。)

I decided to manually force creation of app thumbnail using onCreateThumbnail() as proposed here. (To simplify the task for the beginning, I do not catch a real snapshot but take the splashscreen drawable.)

@Override
public boolean onCreateThumbnail(Bitmap outBitmap, Canvas thumbCanvas) {
    super.onCreateThumbnail(outBitmap, thumbCanvas);

    //splashscreen drawable to bitmap
    outBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.titel);

    //automatically scale to provided canvas 
    //(is the canvas provided as input ???)
    thumbCanvas.drawBitmap(outBitmap, 0, 0, new Paint());

    //is the outBitmap itself scaled to canvas or its copy???
    return true;
}

我不知道,如果上面的code是正确的,因为我无法测试(见下文)。

I am not sure if the code above is correct because I cannot test it (see below).

<一个href=\"http://developer.android.com/reference/android/app/Activity.html#onCreateThumbnail%28android.graphics.Bitmap,%20android.graphics.Canvas%29\"相对=nofollow>根据文档另一个可能的解决方案可能是只是一个虚拟@覆盖onCreateThumbnail只有super.onCreateThumbnail()内,因为文档说:

According to docs another possible solution may be just a dummy @Override onCreateThumbnail with only super.onCreateThumbnail() inside, since the docs say:

默认实现返回失败,并没有得出一个
  缩略图; 这将导致该平台创建其自己的缩略图
  如果需要的话。

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

的onCreateThumbnail方法不火,至少在我的Andr​​oid 2.其实招的目的是在Android上工作3+。
同样是<一个href=\"http://stackoverflow.com/questions/9130599/how-to-change-the-snapshot-shown-by-recent-apps-list\">reported在这里(2012年) 和这里(2009年)。在这两种情况下使用Android版本没有规定。

But the onCreateThumbnail method doesn't fire, at least on my Android 2. Actually the trick is designed to work on Android 3+. The same is reported here (year 2012) and also here (year 2009). In both cases used Android version is not specified.

因此,你请提问帮助:

1)将在code以上工作的,使用缩略图在最近使用的应用列表的Andr​​oid设备3+?

1) Will the code above work on Android 3+ devices that using thumbnails in Recent apps list?

2)如果没有,有没有其他的解决方法,以使应用程序产生一个正确的缩略图(或任意绘制到我的选择)?

2) If nope, is there any other workaround to make the app to generate a correct thumbnail (or arbitrary drawable to my choice)?

在此先感谢!

推荐答案

这是与操作系统的一个问题。不幸的是,它似乎没有工作。如果你不希望人们看你的应用从最近用过出于某种原因,你可以把

This is an issue with the OS. Unfortunately, it just doesn't seem to work. If you don't want people looking at your app from the recents for some reason, you can put

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE)

正如在的onCreate的第一行()的活性的方法。

As the first line in your onCreate() method of the activity.

这篇关于如何强制应用近期应用列表创建缩略图(快照)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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