Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • This will probably be the answer, once I check it, I will accept it. It's really interesting, but I don't need to know if the server is a Hotspot, since there's no server in my application (all the devices send and receive UDP broadcasts). Thank you very much. Commented Dec 29, 2012 at 17:04
  • There's a small problem with that code. This checks for all interfaces, and if it's not the loopback, then it sets the address to that loopback. But I tried it in my device, and it has 3 interfaces, the loopback (127.0.0.1) that gets discarted correctly, the Hotspot (192.168.1.1) and the "ISP" (10.52.121.XXX). Then it doesn't get the Hotspot wifi, but the last interface there is (in my case, it was the ISP one). Checking if the IP is a private one should be enough anyway, but is there any other way of fixing that? Commented Jan 1, 2013 at 10:23
  • I have updated my answer you can check that now there is one more condition, where name of interace is checked. Names differs on different phone but usually it is eth0 or wlan0, but it should be checked if there are some other names used for wifi interface Commented Jan 1, 2013 at 14:57
  • yes, there is another name. In my case it is the ap0. Commented Oct 13, 2014 at 14:55
  • 1
    FYI, Samsung devices use a different address, I believe it is 192.168.68.1 Commented Nov 26, 2014 at 21:30