Search code examples
androidandroid-asynctaskwakelock

Android: MediaPlayer and AsyncTask Wakelock


I have an Activity that uses AsnycTasks to reset and restart a MediaPlayer after it finishes. This all works fine, but I want the MediaPlayer to continue playback even when the phone's screen is off. My first thought was a "PARTIAL_WAKE_LOCK", and this works great until it is time for the MediaPlayer to re-start it using the AsyncTask, at which point it stops.

How can I keep the screen off but still keep my processes alive?


Solution

  • Try android Services to play your Media files. You can also see this and this.