Sie sind auf Seite 1von 5

sign up

Stack Overflow

log in

Questions Tags Users Badges Unanswered Ask

Read this post in our app!

28

Android launching music player using intent


android

music

Is it possible to open the music app from my app in android, or is it best to write a whole new music app inside of mine. I would rather use
theirs since the user will already be comfortable with it.

share

improve this question


shaneburgess
4,704 9 35 59

Asked
Jun 24 '10 at 22:50

Edited
Jul 29 '10 at 21:50

4 Answers

64

Order By

I found one way to do this.


Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(YOUR_SONG_URI);
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);

Votes

share

improve this answer


shaneburgess
4,704 9 35 59

Answered
Jul 29 '10 at 21:48

works like a charm :) Calvin Sep 16 '13 at 14:00

How to check the media player is app is availbe or not on the device Qadir Hussain Jan 20 '14 at 7:01

This doesn't work on the Nexus 6 (opens in photos app) nbarraille Jul 24 '15 at 21:21
add a comment

17

To simply launch the music player do:


Intent intent = new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER);
startActivity(intent);

share

improve this answer


Rino Farina
906 7 6

please note, that this works only in SDK API level 8 up. grzaks Aug 22 '11 at 11:36

Answered
May 28 '11 at 18:31

plz will you tell me what all things should be done after writing the above code of yours.your help will really be beneficial for me and others Hardik Vora Dec 4 '12 at
12:31

Note that this action was deprecated in favor of CATEGORY_APP_MUSIC Nik Reiman Dec 10 '12 at 10:04

MediaStore.INTENT_ACTION_MUSIC_PLAYER is deprecated!! Nizzy Dec 8 '13 at 0:43


add a comment

11

Is it possible to open the music app from my app in android

Yes and no.


Yes, it is possible to write code to do this.
No, the Intents you would need to use are undocumented and may change in future Android releases. The Music app is just another
app; it is not part of the Android SDK's public API.

share

improve this answer


CommonsWare
560k 74 1317 1378

Answered
Jun 25 '10 at 0:41

You can also try this one.


Intent intent = new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

share

improve this answer


Alex Ivana
1 4

Answered
Jun 5 '14 at 8:27

Your Answer

log in
or

Name

Email

By posting your answer, you agree to the privacy policy and terms of service.

meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc

Post Your Answer

Das könnte Ihnen auch gefallen