I need a simple helper class to do these jobs on API 18 and above:
1- set / get static ip address for the device.
2- set / get dhcp ip address for the device.
public static class IPv4Helper {
public static class ipV4Parameters {
String ipAddress;
String subnetMask; // or int
String defaultGateway;
String dns1;
String dns2;
}
public static boolean isDhcpEnabled() {
...
if (current_wifi_is_on_DHCP)
return true;
else
return false;
}
public static ipV4Parameters getStaticIpV4Parameters() {
...
}
public static ipV4Parameters getDhcpIpV4Parameters() {
...
}
public static boolean setStaticIpV4Address(ipV4Parameters newStaticAddress) {
...
}
public static boolean setDhcpEnabled() {
...
}
}
I've found different solutions to do this but some methods has deprecated and I'm confused witch solution is better. Can somebody help me to fill the methods with the best and more standard way?