4

Is there any way to programatically open the Android Music Player?

I'm sure there is some kind of Intent somewhere but I cannot find it.

James

James
  • 5,137
  • 5
  • 40
  • 80

4 Answers4

6

android.intent.action.MUSIC_PLAYER is your friend. See MediaStore on Android Docs for further information.

James
  • 5,137
  • 5
  • 40
  • 80
hanspeide
  • 2,819
  • 4
  • 25
  • 33
6

Create a new intent:

Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
startActivity(intent);
Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
seema
  • 114
  • 1
  • 2
  • 1
    It is not working for me. My target platform is 8. Please let me know, if you need any additional information.. Please refer this post http://stackoverflow.com/questions/14106494/android-launch-music-player-via-service that I am looking for some help, please help me... – Ramesh Sangili Jan 04 '13 at 22:31
4

Since API level 15: action="android.intent.action.MAIN" category="android.intent.category.APP_MUSIC"

slash33
  • 899
  • 1
  • 11
  • 17
-1

since api 15 android.intent.action.MUSIC_PLAYER is deprecated try this code

try {
                String pkgname = "com.sec.android.app.music";
                PackageManager pkgmanager = getPackageManager();
                Intent intent = pkgmanager.getLaunchIntentForPackage(pkgname);
                startActivity(intent);
            } catch(Exception e) {
                // music player not found
            }

add this code on your on click listener and this will open the default music player

BenMorel
  • 34,448
  • 50
  • 182
  • 322
jai_b
  • 1,113
  • 7
  • 7