Android API 28 GetBitMap投掷“没有这样的专栏”错误

发布于 2025-01-25 02:08:23 字数 736 浏览 4 评论 0原文

在Android API 28上,我正在尝试使用专辑ID为特定专辑的专辑艺术。该代码在getBitMap上丢弃以下

android.database.sqlite.SQLiteException: no such column: _data (code 1 SQLITE_ERROR): , while compiling: SELECT _data FROM album_info WHERE (id=?)

代码:

Uri imageUri_t = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumID);
origImage = MediaStore.Images.Media.getBitmap(contentResolver, imageUri_t);

使用光标查询以获取MediaStore.audio.audiocolumns.album_id列以前收集了专辑ID。我还尝试了MediaStore.audio.albums_id,但同样的结果也会发生。

值得注意的是,它使用API​​ 29中引入的较新的LoadThumnAil在API 29和30中正常工作

origImage = contentResolver.loadThumbnail(imageUri_t, new android.util.Size(256, 256), null);

On Android API 28, I'm trying to get the album art for a particular album using the albumID. The code throws the following error on getBitmap

android.database.sqlite.SQLiteException: no such column: _data (code 1 SQLITE_ERROR): , while compiling: SELECT _data FROM album_info WHERE (id=?)

The code below:

Uri imageUri_t = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumID);
origImage = MediaStore.Images.Media.getBitmap(contentResolver, imageUri_t);

The albumID is collected earlier using a cursor query to get the MediaStore.Audio.AudioColumns.ALBUM_ID column. I also tried with MediaStore.Audio.Albums_ID, but the same result happens.

It's worth noting that it works fine in API 29 and 30 using the newer loadThumnail introduced in API 29

origImage = contentResolver.loadThumbnail(imageUri_t, new android.util.Size(256, 256), null);

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

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

发布评论

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

评论(1

幽蝶幻影 2025-02-01 02:08:23

我发现了。错误有点错误,实际上出现了错误,因为它找不到我要求的路径。我

Uri imageUri_t = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumID);

Uri imageUri_t = ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), albumID);

这线替换了这条线,我认为任何一个专辑tart在API 29及以下的位置都比API 30保持在不同的位置。不确定,但希望这对将来的人对我同样困惑的人有帮助

I figured it out. The error is a bit of misnomer, the actual error came because it couldn't find the path I was requesting. I replaced this line

Uri imageUri_t = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumID);

With this

Uri imageUri_t = ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), albumID);

I assume either album art is kept in a different place on API 29 and below than API 30. Not sure, but hopefully this helps someone in the future who's equally confused as I was

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