How to prevent mediaplayer to stop when screen goes off?
I have a mediaplayer in a Music class that is called from another secondary Activity . It works fine. But when screen goes off (either by timeout or button), the music stops playing, and when coming back and try to close the activity the program goes to "App Not Responding", because an IllegalStateException at a query like mediaplayer.isPlaying() . How can I prevent the mediaplayer to stop when screen goes off? Does it have to be through a service?? Assuming that the answer is yes, I tried to convert the Music class into a service (see below). I also added <service android:enabled="true"