How can i convert the host name to Ip adress?

I used this code

WifiManager wifiManager = (WifiManager)context.GetSystemService(Service.WifiService);
int ip = wifiManager.ConnectionInfo.IpAddress;

but it is giving me a random number like 594914112 and i want it to give me the 192.168.x.x format ...
What can i do >_>

Posts

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    C# has System.Net.IPAddress that accepts an ip address in integer format. Then you can use .ToString() to get it in the format you're used to seeing.

    WifiManager wifiManager = (WifiManager)context.GetSystemService(Service.WifiService);
    int ip = wifiManager.ConnectionInfo.IpAddress;
    
    IPAddress ipAddr = new IPAddress(ip);
    myTextView.Text = ipAddr.ToString();
    
Sign In or Register to comment.