There are many nuances - it depends on whether the connection to the server is via WIFI or mobile. The exchange with the server is possible via a mobile connection but not via wifi when the device is in hibernation.
What are the ways out?
Of course, the easiest option is simply not to let the device fall asleep, but it will quickly devour the battery.
Another option is to make an exchange only when the devil wakes up. Also, the example can periodically wake up the device with the help of AlarmManager and do what you need.
Well, or look towards GCM . By the way there is a magic flag Delay_while_idle .
If the flag is not set to true, it’s still a flag. Otherwise, it will be stored in the GCM servers until the device is awake. It’s a bit like a flag of peace of mind. the old message will be collapsed by the new one).