Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:47:25+00:00 2026-06-10T05:47:25+00:00

Big picture: GUI shows user a list of their playlists. User picks one. Program

  • 0

Big picture: GUI shows user a list of their playlists. User picks one. Program passes chosen playlist to next activity which displays the songs in that playlist.

Problem: I can display the playlists and register the users choice, but I can’t seem to display the songs of that play list.

Yes, I’ve see the following questions:

How to query for songs in playlists on Android SDK?

Given an Android music playlist name, how can one find the songs in the playlist?

What is the String 'volumeName' argument of MediaStore.Audio.Playlists.Members.getContentUri referring to?

As you can see in my code, I’ve done my best to implement those solutions, but to no avail.

Things to keep in mind: I’m testing this on a Galaxy Nexus, so no SDcard. Just internal storage and music in the cloud. I need it to work in any scenario (internal, external, or cloud). It currently works in none of those.

//@SuppressWarnings ("serial)")
public class CreationActivity extends Activity {
private final String [] STAR= {"*"};
//reads in all songs to an array


@Override
public void onCreate (Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    //set layout view and assign to variable
    setContentView(R.layout.creation);
    TableLayout myLayout = (TableLayout)findViewById(R.id.creationLayout);

    try {
        Bundle extras = getIntent().getExtras();

        if (extras!=null){
            //get the desired playlist and ID
            String playlist = extras.getString("playlist");
            Long playlistID = extras.getLong("playlistID");
            ArrayList<song> songs = new ArrayList<song>();

            //read in the songs from the playlist
            String[] proj = {MediaStore.Audio.Playlists.Members.TITLE,
                    MediaStore.Audio.Playlists.Members.ARTIST,
                    MediaStore.Audio.Playlists.Members.DURATION};

            //method 1
            Cursor songCursor = getContentResolver().query(MediaStore.Audio.Playlists.Members.getContentUri(null,playlistID),
                    proj,
                    null,
                    null,
                    null);

            //method 2
            /*
            Cursor songCursor = getContentResolver().query(Uri.parse("content://com.google.android.music.MusicContent/playlists/members"),
                   proj,
                    null,
                    null,
                    null);
            */

            //method 3
            /*
            Uri membersUri = MediaStore.Audio.Playlists.Members.getContentUri("internal", playlistID);
            Cursor membersCursor = managedQuery(membersUri, STAR, null, null, null);
            */

            //then this part with methods 1 and 2
            /*
            if (songCursor.getCount() > 0) {
                songCursor.moveToFirst();
                do {
                    song currSong = new song();
                    currSong.title = songCursor.getString(0);
                    currSong.artist = songCursor.getString(1);
                    songs.add(currSong);
                } while (songCursor.moveToNext());
            }
            songCursor.close();
            */

            //or this part with method 3
        /*
            membersCursor.moveToFirst();
            for(int s= 0; s<membersCursor.getCount(); s++,                           
                      membersCursor.moveToNext()){
                  song currSong = new song();
                      currSong.title = songCursor.getString(0);
              currSong.artist = songCursor.getString(1);
          songs.add(currSong);
            }
            membersCursor.close();
            */

        }else{
            Toast.makeText(getBaseContext(), "No songs",Toast.LENGTH_LONG).show();
        }
    } catch (NumberFormatException e){
    }
}
}   

No errors during compiling. But “Unfortunately Music App has unexpectedly quit.” every time.

Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:47:26+00:00Added an answer on June 10, 2026 at 5:47 am

    I figured it out. The key was to use the playlist ID as a string immediately within the URI. See code below.

    This is the part that will get the playlist names and IDs:

    String[] proj = {MediaStore.Audio.Playlists.NAME, MediaStore.Audio.Playlists._ID};
        Uri playlistUri = Uri.parse("content://com.google.android.music.MusicContent/playlists");
        Cursor playlistCursor = getContentResolver().query(playlistUri, proj, null, null, null);
        if (playlistCursor.getCount() > 0) {
            playlistCursor.moveToFirst();
            do {
                nameList.add(playlistCursor.getString(0));
                idList.add(playlistCursor.getLong(1));
            } while (playlistCursor.moveToNext());
        }
    

    Then once you have the playlist ID you can query for the songs in the playlist. This is the part of code that actually queries for the info and puts it all in an array list. NOTE: “song” is a class I have defined elsewhere, where readSong is a method that assigns values to various values (title, artist, etc).

    ArrayList<song> songs = new ArrayList<song>();
    
                //read songs into library from the correct playlist
                String[] proj = {MediaStore.Audio.Playlists.Members.TITLE, MediaStore.Audio.Playlists.Members.ARTIST, MediaStore.Audio.Playlists.Members.DURATION, MediaStore.Audio.Playlists.Members._ID};
                Uri songUri = Uri.parse("content://com.google.android.music.MusicContent/playlists/" + playlistID + "/members");
                Cursor songCursor = getContentResolver().query(songUri, proj, null, null, null);
                if (songCursor.getCount() > 0) {
                    songCursor.moveToFirst();
                    do {
                        //create dummy song
                        song currSong = new song();
                        //read info to dummy var
                        currSong.readSong(songCursor);
                        //add instance to collection
                        songs.add(currSong);
                    } while (songCursor.moveToNext());
                }
                songCursor.close();
    

    I hope this helps anybody else who was struggling with this!! Let me know if you have any comments on my method or ways to make it better!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The picture shows these little gaps. The big, blue containers between the gaps are
I have some big picture and I want to put it to the one
The big picture: I'm working on a search form where the user can choose
I want to fadeOut the current big picture in the #inner_left div by clicking
I'm just looking a big picture idea here; I can google specifics once provided
For big software, take notes is useful for understanding the big picture. How you
I have a big makefile that I have configured with several phony targets. One
Big picture: I want to render an RGB image via GTK on a linux
My big picture goal is to have a grey field over an image, and
This is a big-picture question... but I also have details on the problem I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.