Hi can any one help in solving the below issue
>From my application, I am able to switch on/off WIFI in my device and
able to scan the available networks, but i am UNABLE TO CONNECT TO
specified available network through my applicaiton on the device.
could anyone please show way to connect to specified available
network. please check the code that i am using, and update me is it
the write way or not

if(wifi.getWifiState()==wifi.WIFI_STATE_DISABLED)
{ wifi.setWifiEnabled(true);

    }
    if(wifi.startScan())
    {
        //ls=(ArrayAdapter<ScanResult>) wifi.getScanResults();
        ls=wifi.getScanResults();

        Log.e("",ls.get(0).toString());
        for(int i=0;i<ls.size();i++)
        {   Log.e("VALUE"," "+ls.get(i).toString());
            Log.e("",""+ls.get(i).SSID);
            if(ls.get(i).SSID.equalsIgnoreCase("SPECTRUM-GREEN"))
            {
                Log.e("","SPectrum GREEN FOUND.....");

        try{
            String ssid="\""+ls.get(i).SSID+"\"";
            Log.e("SSId"," "+ssid);
            config.SSID=ssid;
        }catch(Exception e){Log.e("","Error : "+e.toString());}

        config.preSharedKey="\"password\"";
        config.status=WifiConfiguration.Status.ENABLED;

 
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
 
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
 
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
 
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
 
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);

 
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
 
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

        int res=wifi.addNetwork(config);
                Log.e("ENABLE ",""+wifi.enableNetwork(res, false));

                break;
            }
        }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to