Check data connection
suggest changeThis method is to check data connection by ping certain IP or Domain name.
public Boolean isDataConnected() {
try {
Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 8.8.8.8");
int returnVal = p1.waitFor();
boolean reachable = (returnVal==0);
return reachable;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents