Here , i wanna display list of Available Wifi devices ..
This is my code please anyone help me , i do not understand what mistake is
here ?
Please anybody help me here , i wanna display list of Available Wifi
devices, i am very new to this Technology ..
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (wifi.isWifiEnabled() == false)
{
Toast.makeText(getApplicationContext(), "wifi is
disabled..making it enabled", Toast.LENGTH_LONG).show();
wifi.setWifiEnabled(true);
}
String[] str1 = null;
ArrayAdapter<String>adapter=new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,android.R.id.text1,str1);
lv.setAdapter(adapter);
//lv.setAdapter(this.adapter);
WifiInfo info = wifi.getConnectionInfo();
textStatus.append("\n\nWiFi Status: " + info.toString());
// wifiConfig=new WifiConfiguration();
// wifiConfig.status=WifiConfiguration.Status.ENABLED;
boolean b=wifi.isWifiEnabled();
if(b){
wifi.setWifiEnabled(false);
Toast.makeText(getApplicationContext(), "Yes", Toast.LENGTH_SHORT).show();
}
else{
wifi.setWifiEnabled(true);
Toast.makeText(getApplicationContext(), "No", Toast.LENGTH_SHORT).show();
}
wifi.startScan();
List<ScanResult> results = wifi.getScanResults();
for (ScanResult result : results) {
Toast.makeText(this, result.SSID + " " +
result.level,Toast.LENGTH_SHORT).show();
List<WifiConfiguration> configs = wifi.getConfiguredNetworks();
for (WifiConfiguration config : configs) {
textStatus.append("\n\n" + config.toString());
}
if (receiver == null)
//receiver= new WiFiScanReceiver(this);
registerReceiver(receiver, new IntentFilter(
WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
Log.d(TAG, "onCreate()");
}
}
--
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