I'm building a music player which plays songs from the internet. What I notice is that, often, when a song ends and another one has to be loaded, the app does not play the following song.
I wait, wait, wait when finally I decide to unlock my phone to understand what's happening. Surprisingly immediately after the device has been unlocked the following song starts.
The first time I thought it was just a coincidence, but after many times the same thing happened now I think it is systematic. The only cause I can imagine is the Doze mode (I'm using a device with Android 7.1), I've already configured the app to use a WakeLock
(a PowerManager.PARTIAL_WAKE_LOCK
) but it does not seem to be much help.
Edit
I'm sure the problem is the Doze mode. If the device is plugged or if the screen is on (or both) the problem vanishes. If I add my app to the unoptimized apps' list also it works well.