title: Android: Wifi is turned off even with WifiLock
body: <p>I have a foreground service that runs as long as I have a Wifi connection. During the duration of the service it holds a WifiLock. Everything works fine until I turn off the screen and wait about 15 minutes. My socket that I hold then throws a connection timeout exception because the Wifi disconnects (I see it in the logs and my android.net.wifi.STATE_CHANGE broadcast receiver is started). The Wifi then proceeds and gets a new connection.</p>
  
  <p>Bwt the same thing happens if I remove my WifiLock and instead change the Wifi sleep policy to "never". But without either the wifi is just turned off until the screen is unlocked.</p>
  
  <p>Couldn't find anything that solved this problem, any suggestion/workarounds are appreciated. If not, my service will just use the new connection and I will have to build around this issue.</p>
  
  <p>Using a Galaxy Tab.</p>