You were listening to an audio or music stream from your app and suddenly the playback got interrupted. This article explains why this occurs and how to resolve it.
You integrated a podcast or some other audio streaming service with your app and while listening to an audio or music stream, this got interrupted. You observed that this was around 5minutes after your Android device was locked.
Streaming audio on Android devices is meant to play even when the device is locked. In some cases, the Audio Streaming/Playing service stops the audio 5 minutes after the device is locked, and in some rare cases, causes the app to crash.
The reason behind this is that Google has implemented a way to mitigate the most significant challenge that mobile devices face today – poor battery life. Actually, Google introduced methods to reduce battery consumption when the screen is locked and an app appears to be idle for a certain period of time. A side effect of this that some apps that are still executing processes in the background, cease to function as expected
Note: Google from version Android v6.0 onwards introduced the Doze mode. To overcome this, some apps come with what is called a WakeLocks functionality built into them, which prevents some aspect of the device or an operating system from entering a power-saving state. Without such WakeLocks, you would never receive your WhatsApp messages, your Gmail notifications, or your daily alerts. While the Doze mode is designed to curb these battery-hungry WakeLocks, it has been designed intuitively to allow just for high priority notifications.
Go to Settings on the Android device running Android 6.0 Marshmallow and newer.
Scroll down to find the Battery tab and open it.
Open Battery optimization on the screen.
From the list of apps, scroll to find the one you want to disable Doze mode for.
Tap on the app icon and select the Don’t optimize option.
Press the Done button to confirm your selection and exit the Settings app.
- Listen to the audio stream again
You will be able to listen to your music stream without interruption even 5 minutes after your Android device is locked.
Please sign in to leave a comment.