Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android display only mp3 with ACTION_GET_CONTENT

I'm trying to display just MP3 files with:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/mp3");
startActivityForResult(Intent.createChooser(intent, "Music File"), FIND_MUSIC);

But it ends up listing *.3gp files as well. How can I limit to just *.mp3 files only?

I've tried setType("mp3") but then the intent isn't able to find any app that loads the file.

like image 270
user970415 Avatar asked Oct 04 '11 06:10

user970415


2 Answers

The correct MIME type you need to pass to setType to show only mp3 files is "audio/mpeg3". Also "audio/x-mpeg3" should work. Check this out for a full list of MIME types: http://reference.sitepoint.com/html/mime-types-full

like image 90
Adrián Pérez Avatar answered Nov 15 '22 03:11

Adrián Pérez


"audio/mpeg3" did not work for me. I logged the mime type of mp3,

mimeType = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension("mp3");
        Log.e("mime:", mimeType);

It was "audio/mpeg"

like image 34
Debanjan Avatar answered Nov 15 '22 03:11

Debanjan