Hey everyone! I’m working on an Android app and I’m trying to figure out how to make it play songs on Spotify. What I want to do is send a song title from my app to Spotify and have it start playing right away. I know Shazam can do this, so it must be possible, right?
I found some code online that I thought might work, but when I tried it, nothing happened. Here’s what I used:
Intent spotifyIntent = new Intent(Intent.ACTION_MAIN);
spotifyIntent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
spotifyIntent.setComponent(new ComponentName("com.spotify.music", "com.spotify.music.MainActivity"));
spotifyIntent.putExtra(SearchManager.QUERY, "Queen Bohemian Rhapsody");
Does anyone know if there’s a way to make this work? Or is there a better method to get Spotify to play a specific song from my app? Any help would be awesome!