New in Android Marshmallow is a feature called “Doze mode,” which prevents certain tasks from running if you’re phone’s been sitting idle for a while. The idea here is to save battery life by reducing power draw while you aren’t using your phone.
But if you have a particular app that you want to leave running unchecked, no matter what, you can disable Doze mode for that app. Here’s how to do it.
Open the Settings app and tap Battery. Tap the Options menu button (the three dots in the upper right), then tap Battery optimization. Tap the downward-pointing arrow, then tap All apps from the menu that appears.
Next, tap the name of the app for which you want to switch off Doze mode, and in the box that appears, tap Don’t optimize. Once you’re done, tap Done.
You can turn Doze mode back on at any time—simply repeat the above process, but when prompted, tap Optimize instead.