Yesterday I update my nexus 5 to lollipop and my application stops working, after a little investigation I found the problem the DhcpInfo isn't is returning null on the netmask variable.
I couldn't find any alternative to this class.
You can use getNetworkPrefixLength
method of InterfaceAddress
, which you get from NetworkInterface
. It returns the correct value in Lollipop.
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(ipAddress);
for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
short netPrefix = address.getNetworkPrefixLength());
}
Note: It returns network prefix length, so you'd have to convert it (/24 for 255.255.255.0 etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With