How to query all albums to a given artist

前端 未结 1 521
隐瞒了意图╮
隐瞒了意图╮ 2021-02-03 16:02

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 wa

相关标签:
1条回答
  • 2021-02-03 16:55

    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.

    0 讨论(0)
提交回复
热议问题