如何开始从我的应用程序默认的音乐播放器? [英] How to start the default music player from my app?

查看:104
本文介绍了如何开始从我的应用程序默认的音乐播放器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了的ListView A的应用程序。当我在的ListView轻触项, .OGG 音效档开始播放。不是在我的应用程序,但在用户的默认音乐播放器应用程序。我怎样才能做到这一点?

I make a app with a ListView. When I tap on a ListView item, a .ogg soundfile should start playing. Not in my app, but in the default music player app of the user. How can I do this?

推荐答案

试试这个

Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/song.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);

或者

Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");   
Intent it = new Intent(Intent.ACTION_VIEW, uri);   
startActivity(it);  

http://snipt.net/Martin/android-intent-usage/ <提取/ A>

Extracted from http://snipt.net/Martin/android-intent-usage/

我没有测试过自己。

这篇关于如何开始从我的应用程序默认的音乐播放器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆