Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
- InetAddress inetAddress = enumIpAddr.nextElement();
- if (!inetAddress.isLoopbackAddress()) {
- networkIpAdress = inetAddress.getHostAddress().toString();
- }
- }
- WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
- WifiInfo wifiInfo = wifiManager.getConnectionInfo();
- int ipAddress = wifiInfo.getIpAddress();
- HttpClient httpclient = new DefaultHttpClient();
- HttpGet httpget = new HttpGet("http://ip2country.sourceforge.net/ip2c.php?format=JSON");
- HttpResponse response;
- response = httpclient.execute(httpget);
- HttpEntity entity = response.getEntity();
- entity.getContentLength();
- JSONObject json_data = new JSONObject(EntityUtils.toString(entity));
- String networkIpAdress = json_data.getString("ip");
Add Comment
Please, Sign In to add comment