开发者

Android display only mp3 with ACTION_GET_CONTENT

开发者 https://www.devze.com 2023-04-10 17:18 出处:网络
I\'m trying to display just MP3 files with: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(\"audio/mp3\");

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 f开发者_如何学JAVAile.


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


"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"

0

精彩评论

暂无评论...
验证码 换一张
取 消