3

I have written code for adding open network to wifi configured list.It adds the open network to configured lists and displays the same SSID's in Wifi Settings.but it adds the same network with same name extra but it doesn't shows any open network When i press on the second on alert shows with Security WEP the following text i observed with those same networks

1) Open network 2) remembered , not in range But i want to add open network into my list, why this extra one is added and if i connect the same network it is trying to connect to the (2) one programmatically.Actually I changed secured network to open network for this trial.It displays with open network text and when i press on that one it obtains the address and connects succesfully manually.Why this extra one is adding how can i add the open network to my list.For reference plz see the 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

2

2 Answers 2

0

Try removing SSID and seeing if it works. I was having a similar issue and that worked for me.

Appending and prepending quotes to the SSID, as you did, should work though. Not sure why it doesn't.

Sign up to request clarification or add additional context in comments.

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.