我正在开发一个从wifi列表中选择wifi接入点的android应用程序。我用下面的代码..
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = hotSpotSsid;
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
wifiConfiguration.BSSID = hotSpotBssid;
wifiConfiguration.hiddenSSID = false;
// wifiConfiguration.priority = 1;
// add this to the configured networks
int inetId = wifiManager.addNetwork(wifiConfiguration);
Log.i(TAG,"INetId :"+inetId);
configs = wifiManager.getConfiguredNetworks();
Log.e(TAG,"After adding config :"+configs);
if(inetId < 0) {
Log.i(TAG,"Unable to add network configuration for SSID: "+hotSpotSsid);
return;
}else {
message="\t Successfully added to configured Networks";
Log.i(TAG,message);
}
我的问题是我无法选择wifi接入点。每次显示以前配置的wifi详细信息。
最佳答案
看起来您需要使用disableOthers = true调用WifiManager.enableNetwork
wifiManager.enableNetwork(inetId, true);
关于android - 在Android中选择WiFi接入点?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4173304/