I actually happened upon that code today:

http://stackoverflow.com/questions/1221517/how-to-get-subnet-mask-using-java

private static String intToIP(int ipAddress) {
    String ret = String.format("%d.%d.%d.%d", (ipAddress & 0xff),
            (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff),
            (ipAddress >> 24 & 0xff));

    return ret;
}

public static String GetSubnetMask_WIFI() {

    WifiManager wifiManager = (WifiManager) Global.getMainActivity()
            .getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();

    DhcpInfo dhcp = wifiManager.getDhcpInfo();
    String mask = intToIP(dhcp.netmask);

    return mask;
}

I'm not sure if that's where it came from, but I don't consider it very 
obfuscated.




On Tuesday, February 19, 2013 9:43:35 AM UTC-6, Larry Meadors wrote:
>
> On Tue, Feb 19, 2013 at 8:05 AM, bob <[email protected]<javascript:>> 
> wrote: 
> > Why do you say that? 
>
> Because it's a ridiculously obfuscated solution to a problem with a 
> simple one-line solution: 
>
> InetAddress address = 
> InetAddress.getByAddress(BigInteger.valueOf(actualIpAddressAsInt).toByteArray());
>  
>
>
> Larry 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to