问题描述
我开发一个应用程序,我需要开始默认的音乐应用程序并播放所有歌曲。我已经尝试了一些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
。