Search code examples
androidandroid-studioandroid-imageviewspotify

For the Android Spotify API, how do I get the album artowrk image into an imageView? I've tried using Track but no good


I've tried using Track to grab the album artwork but still nothing is displaying. I'm not sure would Picasso be something that could help - I tried it but again, no luck.

mSpotifyAppRemote.getPlayerApi().subscribeToPlayerState().setEventCallback(playerState -> {
                    final Track track = playerState.track;
                    if (track != null) {
                        Log.d("MainActivity", track.name + " by " + track.artist.name);
                        album_artwork.setImageResource(track.imageUri.hashCode());
                    }
                });

Solution

  • If you are getting the artwork image url. verify url first if image url is valid or not. Then by using Picasso all you need to do is:

    Picasso.get().load(track.imageUri).into(album_artwork);

    Please check Spotify official android sample. https://github.com/spotify/android-sdk/tree/master/app-remote-sample