Get Ip Address Text : IP « Network « Android






Get Ip Address Text

   

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;


 class WifiUtil {
   public static final String getIpAddressText(Context context) {
       WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
       WifiInfo wifiInfo = wifiManager.getConnectionInfo();
       int ipAddress = wifiInfo.getIpAddress();
       String strIPAddess = ((ipAddress >> 0) & 0xFF) + "." + ((ipAddress >> 8) & 0xFF) + "."
               + ((ipAddress >> 16) & 0xFF) + "." + ((ipAddress >> 24) & 0xFF);
       return strIPAddess;
   }

}

   
    
    
  








Related examples in the same category

1.Get Ip Address
2.ip To Dotted Decimal
3.get Local Ip Address
4.Int To InetAddress