Android Eclipse 查询存储在图库之外的图像的缩略图
您是否可以对存储在自定义位置(例如 /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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将图像存储在自定义位置后,您可以调用 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.