Android 仅显示带有 ACTION_GET_CONTENT 的 mp3
我试图仅显示 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") 但意图无法找到任何加载该文件的应用程序。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要传递给 setType 以仅显示 mp3 文件的正确 MIME 类型是“audio/mpeg3”。 “audio/x-mpeg3”也应该可以工作。查看 MIME 类型的完整列表:http://reference.sitepoint.com/ html/mime-types-full
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
“音频/mpeg3”对我不起作用。
我记录了 mp3 的 mime 类型,
它是“audio/mpeg”
"audio/mpeg3" did not work for me.
I logged the mime type of mp3,
It was "audio/mpeg"