I am making an application which makes use of internet.
I am using WiFiInfo Class to know the status of network availble and using WifiManager to enable and manage Wi-fi connection if available.
But the result is Unknown ssid. Also I have modified AndroidManifest.xml to grant permission of android.permission.ACCESS_WIFI_STATE. Maybe someone of you guys can help me ... this is the code:
TextView textWifiManager = (TextView)findViewById(R.id.WifiManager);
TextView textWifiInfo = (TextView)findViewById(R.id.WifiInfo);
TextView textIp = (TextView)findViewById(R.id.Ip);
WifiManager myWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
int myIp = myWifiInfo.getIpAddress();
textWifiManager.setText(myWifiManager.toString());
textWifiInfo.setText(myWifiInfo.toString());
int intMyIp3 = myIp/0x1000000;
int intMyIp3mod = myIp%0x1000000;
int intMyIp2 = intMyIp3mod/0x10000;
int intMyIp2mod = intMyIp3mod%0x10000;
int intMyIp1 = intMyIp2mod/0x100;
int intMyIp0 = intMyIp2mod%0x100;
textIp.setText(String.valueOf(intMyIp0)
+ "." + String.valueOf(intMyIp1)
+ "." + String.valueOf(intMyIp2)
+ "." + String.valueOf(intMyIp3)
);
}
}