WifiInfo.getIpAddress() does not return IPv6 addresses. They do not fit into a Java int.
On Wednesday, February 20, 2013 4:11:42 AM UTC-6, Jxn wrote: > > Den tisdagen den 19:e februari 2013 kl. 18:30:45 UTC+1 skrev Nobu Games: > > Bob was asking for the string representation of an integer IP number. > His solution is correct, straightforward and does not require the > instantiation of three intermediate objects just for getting a simple > string. Your one-liner however creates a BigInteger, then a byte array and > finally an instance of InetAddress which still is not a string. It's > toString method may or may not return the resolved host name in addition to > the IP number string representation. That's not quite the original > requirement. > > > > But his solution isn't that wrong. The "easy" solution are plain wrong if > you have something else than IPv4 addresses. > > > 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]> 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()); > > > > This uses a proper encapsulation at least, which the "simple" and "fast" > solution doesn't. I always prefer Slow and Right before Fast and Wrong. > > You should also allow the compiler to do the low level optimisation. Its > usually better than the programmer in doing that if you don't "optimize" > yourself. > > Happy codeing. > > -- -- 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.

