1
I’m doing applied for SSID scan, very simple. The program is running and is very simple, it has a button to scan, but when using this button, do not get any results. I’ll post the full code here for you:
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void getWifiInfo( Context ctxt ) {
int speed = 0;
String ssid = null;
String bssid = null;
String mac = "00:00:00:00:00:00";
String netmask = "255.255.255.255";
String gateway = "0.0.0.0";
WifiInfo info;
WifiManager wifi = (WifiManager) ctxt.getSystemService(Context.WIFI_SERVICE);{
if (wifi != null) {
info = wifi.getConnectionInfo();
speed = info.getLinkSpeed();
ssid = info.getSSID();
bssid = info.getBSSID();
mac = info.getMacAddress();
gateway = getSigned( wifi.getDhcpInfo().gateway );
netmask = getSigned( wifi.getDhcpInfo().netmask );
System.out.println( "Speed : " + speed
+ "ssid : " + ssid
+ "bssid :" + bssid
+ "macAddress :" + mac
+ "netmaskIp :" + netmask
+ "gatewayIp :" + gateway );
}else{
System.out.println( "Wi-fi is Null");
}
}
}
public static String getSigned(int ips ) {
String ip = "";
for (int k = 0; k < 4; k++) {
ip = ips + (( ips >> k * 8) & 0xFF) + ".";
}
return ip.substring(0, ip.length() - 1);
}
}