3

I'm trying to start the stock music player from my app. I did see a few stackoverflow questions like this one - Intent to open android playlist activity - but that didn't get me anywhere. This is the code I am trying to use right now -

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName
        ("com.android.music","PlaylistBrowserActivity"));
intent.setType(MediaStore.Audio.Playlists.CONTENT_TYPE);
intent.setFlags(0x10000000);
intent.putExtra("oneshot", false);
intent.putExtra("playlist", playlistid);
startActivityForResult(intent,1);

I hit this exception -

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.playlistsonthego/com.example.playlistsonthego.HomeSceen}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.music/PlaylistBrowserActivity}; have you declared this activity in your AndroidManifest.xml?

Can someone point me in the right direction? Thanks!

Community
  • 1
  • 1

1 Answers1

1

Try following

Intent intent = new Intent(Intent.ACTION_PICK);
 intent.setType(MediaStore.Audio.Playlists.CONTENT_TYPE);     
 intent.putExtra("playlist", playlistid);
 intent.putExtra("oneshot", false); 
 startActivityForResult(intent, 1);

what I have changed is from ACTION_VIEW to ACTION_PICK.

Prashant Thakkar
  • 1,383
  • 1
  • 12
  • 15
  • Thanks Prashant! I hit the same exception with ACTION_PICK too, though. And if I remove the setComponent, I get a No Activity found to handle intent exception. – whathojeeves Nov 21 '13 at 10:57