androidgoogle-music

Does new Google Music Beta support end user selection of songs via intents


I have an application that uses ACTION_PICK to allow the user to pick a song. Once that song is picked, the application uses the cursor location and does another intent later on to show the NOW_PLAYING interface. The application worked fine until I installed Music Beta on my droid device. The application then began failing with UnsupportedOperationException. The intent and filters looked like this:

Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("vnd.android.cursor.dir/track");
this.startActivity(intent);

I uninstalled Music Bata and the application again worked fine. Wanted to see if this was a bug related to new Google music application and see if anyone else was having this problem.


Solution

  • Check MusicUtils.java. In there there are some calls to pick a song. They all have:

    intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
    

    On another place I found:

    if (id == RECENTLY_ADDED_PLAYLIST) {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
        intent.putExtra("playlist", "recentlyadded");
        startActivity(intent);
    } else if (id == PODCASTS_PLAYLIST) {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
        intent.putExtra("playlist", "podcasts");
        startActivity(intent);
    } else {
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
        intent.putExtra("playlist", Long.valueOf(id).toString());
        startActivity(intent);
    }
    

    In both files the Intent is routed with Uri.EMPTY