gpt4 book ai didi

android - 从 Mediastore 获取全屏缩略图 - Android

转载 作者:行者123 更新时间:2023-11-29 21:06:32 32 4
gpt4 key购买 nike

尝试从媒体存储中获取 FULL_SCREEN_KIND 缩略图时,我不断收到“Unsupported kind: 2”错误。我知道 URI 是一个有效的图像(因为我事先已经变小了)。我的错误在哪里?谢谢。

我的代码

Long myURI = Long.parseLong(record.getString("FILE_ID"));

if (record.getString("FILE_TYPE").equalsIgnoreCase("image")) {

Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(mContext.getContentResolver(), myURI ,MediaStore.Images.Thumbnails.FULL_SCREEN_KIND, (BitmapFactory.Options) null);
return bitmap;

}

else if (record.getString("FILE_TYPE").equalsIgnoreCase("video")) {

Bitmap bitmap = MediaStore.Video.Thumbnails.getThumbnail(mContext.getContentResolver(), myURI, MediaStore.Video.Thumbnails.FULL_SCREEN_KIND, (BitmapFactory.Options) null);
return bitmap;

}

LogCat

06-22 15:24:05.160    3510-3935/com.diverg.tidy I/asd﹕ ID: 50735
06-22 15:24:05.910 3510-3935/com.diverg.tidy W/dalvikvm﹕ threadid=21: thread exiting with uncaught exception (group=0x41ab3ba8)
06-22 15:24:05.941 3510-3935/com.diverg.tidy E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-8183
Process: com.diverg.tidy, PID: 3510
java.lang.IllegalArgumentException: Unsupported kind: 2
at android.provider.MediaStore$InternalThumbnails.getThumbnail(MediaStore.java:670)
at android.provider.MediaStore$Images$Thumbnails.getThumbnail(MediaStore.java:1022)
at com.diverg.tidy.LightboxImageManager.getBitmap(LightboxImageManager.java:105)
at com.diverg.tidy.LightboxImageManager.access$400(LightboxImageManager.java:32)
at com.diverg.tidy.LightboxImageManager$ImageQueueManager.run(LightboxImageManager.java:250)
at java.lang.Thread.run(Thread.java:841)

最佳答案

http://developer.android.com/reference/android/provider/MediaStore.Video.Thumbnails.html

似乎“种类”参数应该是 MICRO_KIND 或 MINI_KIND。

关于android - 从 Mediastore 获取全屏缩略图 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24357473/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com