I'm trying to develop a method that checks if an IP direction is reachable and I found a similar question but it doesn't work Android Application Ping IP number
private void existePingServidor(){
InetAddress in;
try{
in = InetAddress.getByName("90.0.0.122");
if (in.isReachable(5000)){
pingServidor = true;
Log.v("true","He pasado por aquí");
}
else
pingServidor = false;
Log.v("false", "No he podido alcanzar la ip");
}
catch(Exception e){
e.printStackTrace();
}
}
The problem seems that InetAddress.getByName("90.0.0.122"); returns null
¿Can you explain me what is the proper way to ping a Ip in android studio please?