hmkcode / Android

Android related examples
3.51k stars 3.41k forks source link

How to Play music in Google Play music or any media player app by pressing a button in activity of your app? #45

Open junaiiiid opened 5 years ago

junaiiiid commented 5 years ago

Hi, I'm making an app with a music widget it has the following buttons. Play, Pause, Previous track and Next track. how do I play music in the google play music app just by pressing the play button? any help would be appreciated thankyou.

kkshitij-agrawal commented 5 years ago

If you're building the app using the android studio, you will have to activate the mediaplayer service ie, music playing in the background.

iamyashh commented 5 years ago

You can try something of this sort, Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.google.android.music"); startActivity(intent); This would directly take you to the Google Play Music App. Hope this helps you @junaiiiid .