问题描述
我需要一种方法来显示给定的艺术家的所有专辑。所有我迄今发现IST的方式列出其中包含艺术家的至少一个songe所有专辑 - 但是这不是我想要的。我是新到Android的帮助将是非常美联社preciated。预先感谢的!
I need a way to display all albums of a given artist. All I found so far ist a way to list all albums which contain at least one songe of the artist - but that's not, what I want. I'm new to android an help would be very appreciated. Thank's in advance!
推荐答案
这可能远远晚,但它可能是有趣的,其他人:
It may be far to late but it may be interesting to someone else:
我有同样的问题,只有发现晦涩的解决方案如何查询通过特定的艺术家所做的所有专辑,然后我想出了这个简单的解决方案:
I had the same problem and only found obscure solutions how to query all albums done by a specific artist, then I came up with this rather simple solution:
Uri.Builder builder = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI.buildUpon();
builder.appendPath(artistId);
builder.appendPath("albums");
cursor = parent.managedQuery(builder.build(), projection, null,
null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
编辑:将上述溶液,以获得开放的可能不是最好的,这也应该工作:
The above solution to get the Uri may be not the nicest, this should also work:
Uri uri = MediaStore.Audio.Artists.Albums.getContentUri("external", artistId);
该artistId是 MediaStore.Audio.Artists._ID
的从previous艺术家查询的价值。
The artistId is the value of the MediaStore.Audio.Artists._ID
from a previous Artist query.
这篇关于如何查询所有专辑给定的艺术家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!