how to keep internet connection active when in sleep mode android marshmallow' I noticed app background service not working that, when I would use my device after it had been sleeping, wifi wouldn't be connected using marshmallow .
Go to Settings, then click on WiFi. A somewhat similar screen will be shown:



Click on More.



Select "Keep WiFi on during sleep". If any option comes after that, choose "Keep always on during sleep". That's it.

This only happens with WiFi. Mobile data is never switched off by default unless you specifically ask the phone to do so by changing settings to conserve data.