Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Network access when the Android phone is asleep

I'm using a combination of alarm (set with AlarmManager) and background service to periodically synchronize data in my application.

The only problem I have is that when sleep policy terminates Wi-Fi connection the synchronization no longer works.

Is there a way to "wake up" the Wi-Fi connection that has been put to sleep? GMail somehow manages to do that because it notifies me about new e-mail even if the phone entered sleep mode.

like image 819
Marek Stój Avatar asked Mar 21 '10 12:03

Marek Stój


People also ask

Will sleep mode disconnects network connection?

Related. To save energy, Windows automatically disables the Internet connection when the computer goes into sleep mode. This setting logs off the computer user and severs the computer's connection to the local area network, disrupting office network applications and periodic computer updates and messages.

Why does my Wi-Fi turn off when I turn off my phone?

Battery-saving modes can switch your wifi off. Unfortunately, it might not switch back on right away when you want to use it. This can also be common when your phone is in sleep mode. Battery-saving features are one of the most common causes of wifi being shut off on Android.


1 Answers

[update]You can use a WifiLock to keep WiFi active, while holding the lock.

Using an AlarmManager and a Service says to me your service is running only for a very short time!? I think (though can't say for certain) that you should make your service a forground service (check the blog for a good way to implement this on both 1.x and 2.x+) and leave the AlarmManager out of it.

like image 75
MrSnowflake Avatar answered Oct 01 '22 02:10

MrSnowflake