Nick
Nick

Reputation: 9373

Continue to play audio even if the screen is locked

I am just messing around with an app that streams audio and I wanted to give it a feature similar to Pandora/Google Music/etc where if you press home or lock the screen the audio continues to play in the background.

How exactly can I accomplish this? Is it through a broadcast receiver or a service? If I knew more closely what I was looking for Google would be more helpful.

Thanks!

Upvotes: 1

Views: 1076

Answers (1)

CaseyB
CaseyB

Reputation: 25058

It's a service. Anytime you want to do something that takes a lot of time like playing music, downloading a lot of data from a server, etc. it should be a service. The basic technique is to always have the service play the music and then have your activity connect to it to show the status and update the tracks, etc.

Upvotes: 2

Related Questions