1

I created an internet radio application which uses a SHOUTcast radio station and basically plays the predetermined internet radio station when I press Play button. It works fine but when I turn the screen the music pauses and I have to press Play again. It also pauses when the screen is locked after a while. How can I prevent the music to be stopped?

Thanks,

polerto
  • 1,750
  • 5
  • 29
  • 50

1 Answers1

1

You have 2 issues: first, you are probably not properly handling the screen rotation/orientation changes. Take a look at this for some guidance on approaches to that. The second issue is that the network is probably being disconnected when the screen locks: you might need to grab a wake lock to prevent that or explicitly prohibit wifi sleeping. Take a look at this answer: How do I keep Wifi from disconnecting when phone is asleep? for some guidance on that.

Community
  • 1
  • 1
Femi
  • 64,273
  • 8
  • 118
  • 148
  • 1
    Additionally, if you fireant want's to be able to use the device for anything else while listening, the playing should be done in a Service rather than an Activity. – Chris Stratton Apr 29 '12 at 23:45