How to query all albums to a given artist

╄→гoц情女王★ 提交于 2019-12-03 08:00:28

问题


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!


回答1:


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);

Edit: 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);

The artistId is the value of the MediaStore.Audio.Artists._ID from a previous Artist query.



来源:https://stackoverflow.com/questions/8596419/how-to-query-all-albums-to-a-given-artist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!