how to turn off doze mode for specific apps in marshmallow devices programmatically
问题 Marshmallow APIs are very different from previous android OS. When screen is off, devices are in doze mode and unable to sync network. So for doing background operations with network we have to prevent from doze mode. 回答1: Add below permission to manifest.xml <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/> Call below method public void turnOffDozeMode(Context context){ //you can use with or without passing context if(Build.VERSION.SDK_INT >= Build