Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid fast switch to known wifi network
    primarykey
    data
    text
    <p>I am trying to write some code that will disconnect current wifi network (if any) and reconnect to a specific wifi network with known SSID.</p> <p>I have been following the code used here; <a href="https://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically">How do I connect to a specific Wi-Fi network in Android programmatically?</a></p> <p>which works but the connection takes several seconds, upto about 10 seconds.</p> <p>Specifically, I use the code as follows;</p> <pre><code>WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE); WifiConfiguration config; </code></pre> <p>I obtain the config, whether by creating a new one and setting the SSID and KeyMgmt to NONE and then adding it;</p> <pre><code>wifiManager.add(config); </code></pre> <p>or by getting a config that already exists;</p> <pre><code>List&lt;WifiConfiguration&gt; list = wifiManager.getConfiguredNetworks(); for( WifiConfiguration i : list ) { if(i.SSID != null &amp;&amp; i.SSID.equals("\"" + networkSSID + "\"")) { config = i; break; } } </code></pre> <p>Then I call;</p> <pre><code>wifiManager.disconnect(); wifiManager.enableNetwork(i.networkId, true); wifiManager.reconnect(); </code></pre> <p>I have a broadcast received checking the wifi state and when i get a connected for my correct SSID i can continue, however, this process takes upto 10 seconds, how can i set up the config or wifimanager to connect to this much quicker?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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