Saturday, September 17, 2011

Get IPAddress On Your Android Device


WifiManager wifiManager = (WifiManager) getSystemService(WifiInfo wifiInfo = wifiManager.getConnectionInfo();
 ipAddress = wifiInfo.getIpAddress();
 SIpaddress =  String.format("%d.%d.%d.%d", (ipAddress & 0xff),(ipAddress >> 8 & 0xff),
    (ipAddress >> 16 & 0xff),(ipAddress >> 24 & 0xff));


AndroidManifest Setting:


<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />