4

I want to play a playlist in the Google Music Application from another application that I develop. I use this code :

public void play5(String id, String playlistId, String playlistName) {
    Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
    intent.putExtra(MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE, "android.intent.extra.playlist" );
    intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "vnd.android.cursor.item/playlist");
    intent.putExtra("android.intent.extra.playlist", playlistName);
    intent.putExtra(SearchManager.QUERY, "playlist " + playlistName);
    if (intent.resolveActivity(getContext().getPackageManager()) != null) {
        getContext().startActivity(intent);
    }
}

With this function, I can play a playlist in Google Music but if in the name of the playlist, I have the name of an artist, the google music app doesn't play the playlist but a radio about the artist.

Anybody have an idea to always play the playlist in the google application ?

0 Answers0