Android Eclipse 查询存储在图库之外的图像的缩略图

发布于 2024-12-22 06:06:02 字数 143 浏览 3 评论 0原文

您是否可以对存储在自定义位置(例如 /sdcard/testimages)的图像使用 MediaStore 的 queryMiniThumbnails 方法?

当您将新图像添加到该自定义位置时,它是否会自动生成缩略图,或者这是我在添加照片时必须执行的操作?

Are you able to use MediaStore's queryMiniThumbnails method on images that you store in a custom location (for example /sdcard/testimages)?

When you add a new image to that custom location, does it automatically generate a thumbnail, or is that something I would have to do as I am adding the photos?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

马蹄踏│碎落叶 2024-12-29 06:06:02

将图像存储在自定义位置后,您可以调用 MediaScannerConnection.scanFile(String path, String mimeType) 立即添加它。我相信这应该将其添加到图库中,从而为其生成缩略图。然后您可以使用 queryMiniThumbnails 方法。

还有一个带有回调的 scanFile 便捷版本,可以为您设置 MediaScannerConnection 并实现回调,以便您可以在完成后对结果进行操作:
scanFile(Context context, String[] paths, String[] mimeTypes, MediaScannerConnection.OnScanCompletedListener 回调)

请尝试一下。我还没有测试过这个确切的工作流程,所以不确定它是否有效。

After you store the image in your custom location, you can call MediaScannerConnection.scanFile(String path, String mimeType) to have it added right away. I believe this should add it to the Gallery and thus generate a thumbnail for it. You could then use the queryMiniThumbnails method.

There's also a convenience version of scanFile with a callback that sets up the MediaScannerConnection for you and implements a callback so you can operate on the results when it is done:
scanFile(Context context, String[] paths, String[] mimeTypes, MediaScannerConnection.OnScanCompletedListener callback)

Please give this a try. I haven't tested this exact workflow so not sure if it will work out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文