-1

I developed one application which is having set of activities and one background service , this application will talk to the server over WiFi, so when device is in active state my application is able to communicate with the server over Wifi but when device goes to sleep/locked state, after some time connection is getting close. So now able to understand why it is happening, it seems like Wifi is getting turned off automatically when device goes to sleep mode. Is there any way to set the WiFi state as On when my application is running either in foreground or in background?

Please share your idea with some samples.

Regards, Piks

piks
  • 1,621
  • 8
  • 32
  • 59
  • I tried to use below code which have been suggested in above link in my service onCreate method:Settings.System.putInt(getContentResolver(), Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_NEVER); but no positive outcome, wifi connection is still turning off and after some time my app ask for connect. – piks Dec 19 '11 at 06:46
  • I have used WiFiManager to create the WiFi lock and acquire the lock in Service onCreate method, which ensures that WiFi will not get turned off even device goes to sleep mode. – piks Dec 19 '11 at 09:45

0 Answers0