가능한 중복 : 아래
How to get ip address of the device?어떻게 외부/IP를 얻을 수 있습니까?
내가 외부 IP를 얻기 위해 노력하고 방법의 조각입니다. 그러나 ... 아무것도 반환하지 않습니다
public String getIpAddress() {
try {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://www.whatismyip.com/?404");
// HttpGet httpget = new HttpGet("http://whatismyip.com.au/");
// HttpGet httpget = new HttpGet("http://www.whatismyip.org/");
HttpResponse response;
response = httpclient.execute(httpget);
//Log.i("externalip",response.getStatusLine().toString());
HttpEntity entity = response.getEntity();
entity.getContentLength();
str = EntityUtils.toString(entity);
}
catch (Exception e)
{
}
return str;
}
로그 고양이는 어디에 있습니까? –