DhcpInfo not responding to network mask in Android Lolipop

Yesterday I upgrade my nexus 5 to lollipop and my application stops working, after a little investigation, I found that the DhcpInfo problem does not return null in the netmask variable.

I could not find an alternative to this class.

Any ideas?

Hi

+5
source share
1 answer

You can use the getNetworkPrefixLength InterfaceAddress method that 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 the length of the network prefix, so you have to convert it (/ 24 for 255.255.255.0, etc.).

+6
source

Source: https://habr.com/ru/post/1206885/


All Articles