启动默认的音乐播放器在默认情况下播放音乐 [英] Start default music player with music playing by default

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

问题描述

我开发一个应用程序,我需要开始默认的音乐应用程序并播放所有歌曲。我已经尝试了一些codeS,但似乎没有任何工作。

I am developing an application where I need to start the default music app and play all the songs. I have tried a number of codes but nothing seems to work.

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(
                          "com.android.music.MediaPlaybackActivityStarter");
startActivity( LaunchIntent );

Intent intent = new Intent();
ComponentName comp = new ComponentName("com.android.music",
    "com.android.music.MediaPlaybackActivity");
intent.setComponent(comp);
intent.setAction(Intent.ACTION_RUN);
startActivity(intent);

刚刚起步的音乐播放器

Just starts the music player

Intent i = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,  "1");
startActivity(i);

刚刚播放的第一首歌。

Plays just the first song.

我需要打所有歌曲。

请帮忙。

推荐答案

使用此为低于15 API

Use this for api below 15

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

和以后使用 android.intent.category.APP_MUSIC

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

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