Turn off WiFi only when the device is both locked and screen turned off I have already tested some apps for this purpose and they solely rely on the screen turning off, which makes sense at some point. However, their concept breaks down when you want to use an app over WiFi which has the capability to turn-off the screen due to the proximity sensor (think of the VoIP apps). Turning off the screen in that case means disconnection from the network.

Is it possible to turn off the WiFi only if the device is both locked and screen turned off?
If I understand your question correctly, then there is a very easy way of doing this yourself. Im sure there are many ways of going about this, but this is the easiest and most reliable method that I know of.

You said that you wanted something that doesn't rely on the screen being off. My solution does rely on the "display" being off, however for the "display" as opposed to the "screen" to be off, the device must be locked, meaning that this should work flawlessly for you.

If you just follow the instructions I've provided below, you should have satisfying results in just a few minutes!




Download Tasker from the Play Store.
Open Tasker and click the + button. Now click Event &rarr; Display &rarr; Display Off.
Click the gear (back button) in the top left corner. A pop up menu will appear. Select New Task and name it Display Off.
Tap + &rarr; Net &rarr; WiFi and make sure the box that says Set is set to Off.
Click the gear (back) twice so that you end up on the Profiles screen.
Now click + again, then Event &rarr; Display &rarr; Display On.
Tap the gear (back) and then select New Task. Name it something along the lines of Display On.
Click + &rarr; Net &rarr; WiFi and change Set to On. Now exit back to the Profiles tab. You should now have both Display Off and Display On.
In the Profiles tab to the right of your conditions, there are On/ Off toggles. Turn both of these to Off and then back to On.
Simply exit out of Tasker and you're done!




Good luck and I hope this helps you!