If a phone is setup to turn off the WiFi when the phone goes into sleep mode, my app will lose it's connection. It is a well documented problem that when some devices come out of sleep mode, the WiFi connection doesn't even reconnect although the WiFi icon indicates that it is connected. I have seen this happen on one of my devices.
But I am at a loss as to how the Gmail app works. Even in sleep mode, if mail comes in, you get notified. Yet if the WiFi is disabled in sleep mode, then the only way the Gmail app can check for mail is to turn on the WiFi. I assume it turns it on and then back off after it is done checking for mail. So how can I accomplish the same thing? Or am I wrong and the WiFi never gets turned off because Gmail always keeps it on? But how would I know that?