4

I am creating an application in which the list of the playlist already created by user in the native music application will be shown in a list and their onclick shall take them to that specific playlist page.

Following is the code which i am using

    Button open = (Button)findViewById(R.id.ope_playlist);

    cursor = playlist.this.managedQuery(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, null
            , null, null, null);
    cursor.moveToFirst();

    final String playlistid = cursor.getString(cursor.getColumnIndex
            (MediaStore.Audio.Playlists._ID));
    cursor.close();

    open.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setComponent(new ComponentName
            ("com.android.music","com.android.music.PlaylistBrowserActivity"));
            intent.setType(MediaStore.Audio.Playlists.CONTENT_TYPE);
            intent.setFlags(0x10000000);
            intent.putExtra("oneshot", false);
            intent.putExtra("playlist", playlistid);
            startActivity(intent);

        }
    });
} 

and this activity is registered in manifest as :-

<activity android:name=".playlist">
        <intent-filter >
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
    </activity>

and i get this error :-

07-22 15:02:02.545: ERROR/AndroidRuntime(11983): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.music/com.android.music.PlaylistBrowserActivity}; have you declared this activity in your AndroidManifest.xml?

Thanks is advance

abhishek
  • 1,434
  • 7
  • 39
  • 71
  • 1
    Got it working by adding the following code in onclick Intent i = new Intent(Intent.ACTION_PICK); i.setType(MediaStore.Audio.Playlists.CONTENT_TYPE); //i.setType(playlistid); i.putExtra("playlist", playlistid); i.putExtra("oneshot", false); startActivityForResult(i, 1); – abhishek Jul 22 '11 at 12:21
  • 1
    You can create your own answer and accept it. Please do so. – ntv1000 Feb 16 '14 at 20:37
  • I'm getting unknown playlist id:389 where 389 is playlist id which is there in Android media provider mapped with a song. what can be the issue? any idea – Nayanesh Gupte Jul 30 '14 at 06:09

0 Answers0