I know how to connect to an access point, but I don't know how to connect to the strongest one, if all have the same SSID.
I configured something like this
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = convertToQuotedString("XYZ");
conf.status = WifiConfiguration.Status.ENABLED;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
int netId = wifi.addNetwork(conf);
and then I say something like this
List<WifiConfiguration> _configs = wifi.getConfiguredNetworks();
for (WifiConfiguration config : _configs) {
if ( config.SSID.equalsIgnoreCase(convertToQuotedString("XYZ"))){
boolean erg = wifi.enableNetwork(config.networkId, true);
Log.d(TAG, "enabling configured Network: " + Boolean.toString(erg) +
" SSID=[" + config.SSID + "] and ID=[" + config.networkId );
}开发者_开发知识库
}
The question now is ? How can I connect to another access point with the same SSID but a better signal ?
In the WifiConfiguration there is no possibility to tell him something this, is it ?
I find a better access point with the same SSID using the method
WifiManager.compareSignalLevel(bestSignal.level, connectedAcc.level) <0
How can I connect to the better one, if in the WifiConfiguration there is no difference between them, because they both have the same SSID ?
I hope you can help me please, thanks a lot
Once you know the best one, you can change the priority in the corresponding WifiConfiguration.
Well if you still haven't found an answer to your issue then you can do as follows -
1) Check whether the BSSID of best signal and the device you have connected to is the same.
a) If its same then it means you are connected to the SSID with the best signal and all is well.
b) If not move to step two.
2) Use wifi.disconnect();
This will ensure that at the moment you are not connected to any access point.
3) Now use the SSID as previously used to connect to the access point and it will connect to the one with the strongest signal.
精彩评论