1

In the Android Universal Music Player, there is an icon which is displayed for a list. However, that icon is not shown. The original source code, set the icon as follow:

        if (MEDIA_ID_ROOT.equals(parentMediaId)) {
            LogHelper.d(TAG, "OnLoadChildren.ROOT");
            mediaItems.add(new MediaBrowser.MediaItem(
                    new MediaDescription.Builder()
                        .setMediaId(MEDIA_ID_MUSICS_BY_GENRE)
                        .setTitle(getString(R.string.browse_genres))
                        .setIconUri(Uri.parse("android.resource://" +
                                "com.example.android.uamp/drawable/ic_by_genre"))
                        .setSubtitle(getString(R.string.browse_genre_subtitle))
                        .build(), MediaBrowser.MediaItem.FLAG_BROWSABLE
            ));
}

I thought there might be issue with the way the uri is handled, so I changed it to the following:

 .setIconUri(Uri.parse("android.resource://" +
                                getPackageName() + "/" + R.drawable.ic_by_genre))

The icon exist in the resource file, however it is not displayed and instead of icon it is simply blank.

Did anybody face similar issue when they tried this sample project? and how to fix it?

Rain Man
  • 1,163
  • 2
  • 16
  • 49
  • Hi look at this issue: http://stackoverflow.com/questions/34607919/not-getting-thumb-with-genres-universal-music-player – Sophie Jan 08 '16 at 07:39

1 Answers1

2

Just a guess, since R.drawable.ic_by_genre is an int, the following code

.setIconUri(Uri.parse("android.resource://" +
                                getPackageName() + "/" + R.drawable.ic_by_genre))

will yield something like

android.resource://[your.package.name]/1234567

which is not what initial code is trying to achieve. Instead go with

.setIconUri(Uri.parse("android.resource://" +
                                    getPackageName() + "/drawable/ic_by_genre")

and don't forget to actually put the icon with this name into the drawable folder.

Egor
  • 39,695
  • 10
  • 113
  • 130
  • yeah still doesn't display the image. I think there is more into this issue, they probably never implemented this in the UI – Rain Man Jul 30 '15 at 22:01