Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Unless your application has a very good reason to keep a Wi-Fi connection, you should really try to respect the user's preference to disable WiFi when the screen locks. Your application will quickly cause the device to consume significantly more power by using any sort of lock. As mentioned by others, in your case, you'll need the <a href="http://developer.android.com/reference/android/os/PowerManager.html#PARTIAL_WAKE_LOCK" rel="noreferrer"><code>PowerManager.PARTIAL_WAKE_LOCK</code></a> to keep the CPU running (without preventing the screen from locking) and <a href="http://developer.android.com/reference/android/net/wifi/WifiManager.WifiLock.html" rel="noreferrer"><code>WifiManager.WakeLock</code></a> to keep Wi-Fi connected.</p> <p>You'll probably find the setting causing this behaviour under the system settings for Wi-Fi, under advanced Wi-Fi settings:</p> <p><img src="https://i.stack.imgur.com/BS1Yi.png" alt="Keep Wi-Fi on during sleep"></p> <p>By disabling this setting on a device with mobile data, your network location listener should still work as Android will continue to use Google's Location API in the background to resolve the device's location based on cellular towers.</p> <p>If your device is also switching off mobile data, perhaps some power-saving application is disabling it. <a href="https://play.google.com/store/apps/details?id=com.daimler.blueefficiency.android" rel="noreferrer">BlueEFFICIENCY</a> and <a href="https://play.google.com/store/apps/details?id=com.latedroid.juicedefender" rel="noreferrer">Juice Defender</a> are some apps that have an option for this optimization, but HTC and Sony have included some power saving options on their devices that may also be exhibiting this behavior.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload