breber / cardgames

Repository for continuation of CS309 Project
https://play.google.com/store/apps/details?id=com.worthwhilegames.cardgames
3 stars 1 forks source link

Remove use of Deprecated method Formatter.formatIpAddress() #2

Closed breber closed 12 years ago

breber commented 12 years ago

In the connection screen on the tablet, we use the method Formatter.formatIpAddress() to display the proper IP address. This method is deprecated as it doesn't work with IPv6 addresses. We should look into finding an alternative that displays a nice IP address that isn't deprecated.

anelson6 commented 12 years ago

I found a site where someone dealt with this issue and used its code to write a method in the ConnectionActivity class that finds the address and then formats it. Here is the link to the site: http://www.droidnova.com/get-the-ip-address-of-your-device,304.html I added a few things to the code because I think it was printing out something other than the IP address before I checked to see if it was IPv4 or IPv6. This change worked for me, but I don't have IPv6 so I don't know if it would work for that. It ditches the WifiInfo class entirely because that can only return an integer IP address, which isn't enough to hold the 16 bytes required for IPv6. Feel free to change anything I added! Or everything.

breber commented 12 years ago

So I had something similar in Util.getLocalIpAddress(). I didn't really modify the code in the demo, so it was showing a complicated IPv6 address (something like ffff::ffff::ffff:ffff), which would be annoying to have to type in. I don't know exactly how it works, but I would think that we would want to stick to using an IPv4 address if it exists.

breber commented 12 years ago

So I tried this, and I am pretty sure it works. I think we have IPv6 set up on our home network, and it is displaying an IPv4 address, which is what I wanted. Thanks for looking into this!