InetAddress.getLocalHost() 또는 InetAddress.getByName (문자열 호스트)을 시도 할 때마다 nba.com과 같은 알려진 웹 사이트에서도 예외가 발생합니다. 조금 혼란 스러워요 참고 대상 장치는 안드로이드 4.1.1 GS3 및 와이파이 및 모바일 네트워크에 있습니다. 59 : 52.636 : I/System.out에 (18996) : 사전에 잡힌 예외 = null이InetAddress를 사용하여 자체 IP 가져 오기
감사
try{
InetAddress ownIP=InetAddress.getLocalHost();
System.out.println("IP of my Android := "+ownIP.getHostAddress());
}catch (Exception e){
System.out.println("Exception caught ="+e.getMessage());
String t = e.getMessage() + "yes";
}
아래 아래 코드는 System.out에
03-12 18
이 게시물 http://stackoverflow.com/questions/6064510/how-to-get-ip-address-of-the-device – Quanturium
를 살펴 보자') (InetAddress.getLocalHost'의 경우 실제로 예외를 던지면 잘못 구성된'hosts' 파일 및/또는 DNS가 있습니다. – EJP