Check data connection

suggest change

Ping a host to see whether it answers. A return code of 0 means this host replied. It does not prove every destination is reachable, and some networks block ICMP. The INTERNET permission is required, and ping must exist on the device.

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;
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents