class PingCheckThread implements Runnable{
@Override
public void run() {
// TODO Auto-generated method stub
while(!Thread.currentThread().isInterrupted()){
try {
if(device != null){
for(int i = 0; i < device.size(); i++){
String info = (String) device.get(i);
int first = info.indexOf(":");
int last = info.lastIndexOf(":");
String ip = info.substring(first, last);
InetAddress targetIp =
Inet4Address.getByAddress(ip.getBytes()); /// error!!
if(targetIp.isReachable(60000)){
Log.v(TAG, "Connection Ok");
}else{
Log.v(TAG, "Connection Fail");
}
}
}
Thread.sleep(60000);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.v(TAG, e.getMessage());
}
}
}
}
보시다시피 InetAddress 에서 오류가 나는데 null point exception 이 납니다.
08-26 11:27:34.124: W/dalvikvm(3612): threadid=13: thread exiting with uncaught exception (group=0x2c43b930)
08-26 11:27:35.464: E/AndroidRuntime(3612): FATAL EXCEPTION: Thread-216
08-26 11:27:35.464: E/AndroidRuntime(3612): java.lang.NullPointerException
08-26 11:27:35.464: E/AndroidRuntime(3612): at com.skb.sportscompanion.tv.SportsCompanionTV$PingCheckThread.run(SportsCompanionTV.java:206)
08-26 11:27:35.464: E/AndroidRuntime(3612): at java.lang.Thread.run(Thread.java:856)
InetAddress.getByName 이나 getByAddress 만 하면 null point exception 이 나는데 이유를 알고 싶습니다.
퍼미션은 설정 하였습니다.