Judge Android application development of WiFi IP network

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
public String getIpAddress(){
        WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        if (wm.getWifiState() == WifiManager.WIFI_STATE_ENABLED)
        {
            WifiInfo info = wm.getConnectionInfo();
           int  hostip = info.getIpAddress();
           String ip = (hostip & 0xFF)+"."+((hostip>>8)&0xFF)+ "." + ((hostip >> 16 ) & 0xFF) +"."+((hostip >> 24 ) & 0xFF);
            Toast.makeText(MainActivity.this, ip, 1).show();
            return ip;
        }
        return null;
    }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Brady at December 11, 2013 - 12:03 AM