android 应用组件[通用 Intent---播放媒体文件] 十五
2017-04-05 10:03
435 查看
如需播放音乐文件,请使用
操作
示例 Intent:
示例 Intent 过滤器:
<activity ...>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:type="audio/*" />
<data android:type="application/ogg" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
ACTION_VIEW操作,并在 Intent 数据中指定文件的 URI 位置。
操作
ACTION_VIEW数据 URI 架构
file:<URI>
content:<URI>
http:<URL>MIME 类型
"audio/*"
"application/ogg"
"application/x-ogg"
"application/itunes"或者您的应用可能需要的任何其他类型。
示例 Intent:
public void playMedia(Uri file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(file); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } }
示例 Intent 过滤器:
<activity ...>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:type="audio/*" />
<data android:type="application/ogg" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
相关文章推荐
- android 应用组件[通用 Intent---打开特定类型的文件] 十二
- android 应用组件[通用 Intent---基于搜索查询播放音乐] 十六
- android 应用组件[通用 Intent---检索特定类型的文件] 十一
- android 应用组件[通用 Intent---联系人/人员应用] 九
- android 应用组件[通用 Intent---显示所有闹铃] 四
- android 应用组件[通用 Intent---设置] 二十
- android 应用组件[通用 Intent---撰写带有可选附件的电子邮件] 十
- android 应用组件[通用 Intent---搜索] 十九
- android 应用组件[通用 Intent---拍摄照片或视频并将其返回] 六
- android 应用组件[通用 Intent---叫车] 十三
- android 应用组件[通用 Intent---创建定时器] 三
- android 应用组件[通用 Intent---创建笔记] 十七
- android 应用组件[通用 Intent---以静态图像模式启动相机应用] 七
- android 应用组件[通用 Intent---发起通话] 十八
- android 应用组件[通用 Intent---加载网址] 二十二
- android 应用组件[通用 Intent---撰写带附件的短信/彩信] 二十一
- android 应用组件[通用 Intent---以视频模式启动相机应用] 八
- android 应用组件[通用 Intent---添加日历事件] 五
- android 应用组件[通用 Intent---显示地图上的位置] 十四
- android 应用组件[通用 Intent---创建闹铃] 二