user2229005
user2229005

Reputation: 11

How to play music in all activities in an application?

I want to play music in all activities in my app but when i press the button to go to the next activity music stops, i used onPause(), onResume and it work properly. I wrote that in other way without onPause() and music played in whole app but when i pressed home button music doesn't stop. I used KeyEvent on home button but there is no reaction, i checked it with back and it works but it doesn't minimize app.

Upvotes: 1

Views: 232

Answers (1)

waqaslam
waqaslam

Reputation: 68177

The simplest solution for this is to use Service. For more info study MediaPlayer sample application available in the SDK.

Upvotes: 1

Related Questions