I am working on android system application. I would like to know if IP address is DHCP or STATIC.
Do we have any android java class for this? Or is there any way to get it from sysfs like /sysfs/class/net/eth0?
I am working on android system application. I would like to know if IP address is DHCP or STATIC.
Do we have any android java class for this? Or is there any way to get it from sysfs like /sysfs/class/net/eth0?
I used this to check wether is DHCP or STATIC years ago, perhaps you can try it out, if it does not work I'll remove the answer.
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo connectionInfo = wifiManager.getConnectionInfo();
List<WifiConfiguration> configuredNetworks = wifiManager.getConfiguredNetworks();
for (WifiConfiguration wificonf : configuredNetworks){
if (wificonf.networkId == connectionInfo.getNetworkId()){
if (wificonf.toString().toLowerCase().indexOf("DHCP".toLowerCase())>-1){
//DHCP
}else if(wificonf.toString().toLowerCase().indexOf("STATIC".toLowerCase())>-1){
//STATIC
}
break;
}
}