Android仅显示mp3文件的ACTION_GET_CONTENT功能

5

我尝试使用以下代码仅显示MP3文件:

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

但它最终也会列出 *.3gp 文件。如何只限制只显示 *.mp3 文件?

我尝试过使用 setType("mp3"),但此时 intent 找不到能够加载该文件的任何应用程序。

2个回答

9

5
"

“audio/mpeg3” 对我无效。 我记录了 mp3 的 mime 类型,

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

这是"audio/mpeg"格式。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接