启动默认的音乐播放器 [英] Launching the default music player

查看:147
本文介绍了启动默认的音乐播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图启动音乐播放器,因此将启动,并立即开始播放第一首歌曲。即时通讯使用的意图,但它只是不工作...它说:没有活动中来处理的意图。

 意向意图=新的意图(android.content.Intent.ACTION_VIEW);
       //songsList是所有歌曲中的SD卡路径数组
    开放的我们的uri = Uri.parse(songsList.get(0));
    字符串类型=音频/ MP3;
    intent.setDataAndType(URI,类型);
    startActivity(意向);
 

解决方案

为什么不使用<一个href="http://developer.android.com/reference/android/provider/MediaStore.html#INTENT_ACTION_MUSIC_PLAYER"相对=nofollow> android.intent.action.MUSIC_PLAYER

 意向意图=新的意图(android.intent.action.MUSIC_PLAYER);
startActivity(意向);
 

请注意,这是由API 15 pcated德$ P $,从API向上可以使用的 android.intent.category.APP_MUSIC

I'm trying to launch the music player so it will launch and immediately start playing the first song. im using an Intent but it just doesn't work...it says "no activity found to handle intent".

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
       //"songsList" is an array with paths of all the songs in the sdcard
    Uri uri = Uri.parse(songsList.get(0));
    String type = "audio/mp3";
    intent.setDataAndType(uri, type);
    startActivity(intent);

解决方案

Why not use android.intent.action.MUSIC_PLAYER?

Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
startActivity(intent);

Note that this is deprecated from API 15, FROM API upwards you can use android.intent.category.APP_MUSIC.

这篇关于启动默认的音乐播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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