Failed to configure wifi open network programmatically using Android?

I wrote code to add an open network to the list of configured Wi-Fi. It adds the open network to the configured lists and displays the same SSID in the Wi-Fi settings. But it adds the same network with the same name, but does not show any open network. When I click on the second one, the following text appears on the warning screen with WEP protection, which I observed on the same networks.

1) An open network 2) remember, but not in a radius But I want to add an open network to my list, why this additional one is added, and if I connect the same network, it tries to connect to (2) programmatically. In fact, I changed the secure network to open the network for this trial version. displays a clear text network, and when I click on it, it gets the address and connects successfully manually. Why does this extra add, how can I add an open network to my list. For plz link see link for image.

http://www.freeimagehosting.net/uploads/3dbccfc2bd.png

Code snippet:

    String hotSpotSsid = hotSpot.SSID;
    String hotSpotBssid = hotSpot.BSSID;
    Log.i(TAG,"in RSSI Changed Acion SSID: "+hotSpotSsid+" BSSID: "+hotSpotBssid);
    StringBuffer sBuf = new StringBuffer("\"");
    sBuf.append(hotSpotSsid+"\"");
    hotSpotSsid = sBuf.toString();

    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);
    }

Regards, Rajendar

+3
source share
2 answers

SSID , . , .

SSID, , . , .

0

SSID wifiConfiguration.SSID = "\" ". concat (SSID_NAME).concat( "\" ");

-1

Source: https://habr.com/ru/post/1759077/


All Articles