Answer the question
In order to leave comments, you need to log in
How to make Android ping external IPs?
Good day! The question is really simple. I am learning Android programming. Made a simple program:
int timeout = 2000;
InetAddress[] addresses = InetAddress.getAllByName(String.valueOf(ad.getText()));
for (InetAddress address : addresses)
{
if ( address.isReachable(timeout))
{
info.setText("OK"); // just set a break point here
} else {
info.setText("NOT OK");
}
}
Answer the question
In order to leave comments, you need to log in
Atata! Update number one (aka last). It is also a partial solution to the problem. Haven't fully figured it out yet! The above code works fine on some phones and doesn't work at all on others! I modestly assume that the answer lies not in the plane of interaction between Java and Dalvik. The reason is not in the code above, not in manifests and permissions. It is most likely in the core. Somewhere Linux was castrated a little more than completely and voila! ICMP is not present in the phone as a class. I don't know the details. For now, I'm just stating a fact!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question