I’m developing an application that interacts with Spotify, and I’m trying to figure out how to prompt the app to play a particular track or search for a user. I’ve experimented with using a Spotify URI like:
String spotifyUri = "spotify:user:someusername";
Uri parsedUri = Uri.parse(spotifyUri);
But this approach merely opens Spotify without triggering any specific action. I found another example that launches Spotify:
Intent spotifyIntent = new Intent(Intent.ACTION_MAIN);
spotifyIntent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
spotifyIntent.setComponent(new ComponentName("com.spotify.mobile.android.ui", "com.spotify.mobile.android.ui.Launcher"));
Unfortunately, this code only starts the app and does not execute a search for a song. Does anyone have guidance on how to modify the intent to search for a track? Any insights are appreciated!