Automatically enable WiFi when you're near a saved network It looks like one feature coming out in 8.0 Android O is the ability to Automatically enable WiFi when you're near a saved network



Can this be accomplished through tasker today?


Add Profile > State > Net > Wifi Near (as in these questions here and here)


Enter SSID Network Name(s) / Select Networks currently in Range


This works one at a time, but ideally, you could pull from the current list of saved/configured WiFi networks.  Android does keep a list of previously saved networks:




Q: But is there anyway to programmatically retrieve all saved network names and set it as a variable?

Note: Some apps exist like SmartWifiToggler, based on GPS, but I'd rather accomplish through tasker if possible.
I had same issue and finally found a link to this project:
https://www.reddit.com/r/tasker/comments/8p0ywt/project_share_switching_to_saved_wifi/
The project itself does a bit more, but shows one way to get the saved wifis with default Tasker features.
So regarding your Q: But is there anyway to programmatically retrieve all saved network names and set it as a variable?
A: Yes, there is, using Tasker action of type Code -&gt; Java Function (see also function $getConfiguredNetworks in the linked project):
1.) Use Code Java Function to get WifiManager from CONTEXT
2.) Use Code Java Function to get configured networks from WifiManager
3.-6.) Use Variable Search Replace to get SSIDs out of the configured networks using regular expression
7.-8.) Set variable to be checked by Tasker Wifi Near State
9.) (Optional) Trigger steps 1-8 automatically
Detailed Tasker actions:
1.) Java Function:
a) Class Or Object=CONTEXT 
b) Function=getSystemService{Object}(String) &lt;select using magnifying glass icon and
either scroll down or use filter on the bottom of the screen, pay attention to not pick the (Class) version&gt;
c) Param=wifi 
d) Return{Object}=(WifiManager) wifiman 
--&gt; result in Tasker view should look like this: (WifiManager) wifiman = CONTEXT.getSystemService(wifi)
2.) Java Function:
a) Class Or Object=wifiman 
b) Function=getConfiguredNetworks{List}() 
c) Return{List}=%get_configured_networks 
--&gt; result in Tasker view should look like this: %get_configured_networks = wifiman.getConfiguredNetworks()
Extract SSIDs, there are many ways, I did it looping over the list
3.) For: Variable %get_configured_networks Items %configured_network
Delete everyting from the variable that is not the SSID using regular expression
4.) Variable Search Replace:
a) Variable=%configured_network
b) Search=(?:.|\n)*SSID:\s*&quot;(.*)&quot;(?:.|\n)* &lt;this regex will capture the SSID name in capture group 1&gt;
c) Replace Matches=true
d) Replace with=$1 
Add SSID to array
5.) Array Push: Variable Array %ssids Position 1 Value %configured_network
End loop
6.) End For
Join SSIDs with / as separator to fit Taskers wifi near syntax SSID1/SSID2/.../SSIDn
7.) Variable Join %ssids Joiner /
Set Global Variable to be checked by Taskers Wifi Near State
8.) Variable Set Name %SavedWifis To %ssids
So once this is done, a Wifi Near %SavedWifis can be used. But after you have added a new Wifi or removed an old one, you need to update the value again.
9.) Execute Taks to refresh %SavedWifis regularly (for example based on time event or whenever wifi connected), if anybody knows a way to react on a 'savedWifisUpdated' event, please let me know.