How to open music picker?

This worked well for me:

public static final int REQ_PICK_AUDIO = 10001;
//------   
Intent audio_picker_intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
activity.startActivityForResult(audio_picker_intent, REQ_PICK_AUDIO);

The more general intent with Intent.ACTION_GET_CONTENT can present the user with a number of options for activities to pick an audio file (Astro file manager, etc.). However, the user could select any file, not necessarily an audio file. I wanted one that simply allowed the user to select an audio file from their media. This did the trick.


If you take a look at the AndroidManifest.xml file for the latest core Music app, it may shed some light on the options that you have. For example:

<activity android:name="com.android.music.MusicPicker"
        android:label="@string/music_picker_title" android:exported="true" >
    <!-- First way to invoke us: someone asks to get content of
         any of the audio types we support. -->
    <intent-filter>
        <action android:name="android.intent.action.GET_CONTENT" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.OPENABLE" />
        <data android:mimeType="audio/*"/>
        <data android:mimeType="application/ogg"/>
        <data android:mimeType="application/x-ogg"/>
    </intent-filter>
    <!-- Second way to invoke us: someone asks to pick an item from
         some media Uri. -->
    <intent-filter>
        <action android:name="android.intent.action.PICK" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.OPENABLE" />
        <data android:mimeType="vnd.android.cursor.dir/audio"/>
    </intent-filter>
</activity>

So based on this, you might first try

final Intent intent2 = new Intent(Intent.ACTION_GET_CONTENT);
intent2.setType("audio/*");
startActivityForResult(intent2, 1);

and see if it fits your needs. You may also look at adding the category flags noted in the above example to help narrow down the results (e.g. OPENABLE should filter to only content that can be opened as a stream.