Check for Internet access Android Studio [duplicated]

0

I am sending data from Android Studio to Mysql using PHP files. my problem is that there will not always be Internet , I've tried several methods that the only thing they do is check if there is internet, all right up there. My problem starts when connected to a Wi-Fi network but there is no internet access. How can I know if there is internet access, that is, not only verify that it is connected to a network, but that there really is?

    
asked by DoubleM 03.01.2017 в 20:52
source

1 answer

0
public boolean conectadoAInternet() throws InterruptedException, IOException
{
    String comando = "ping -c 1 facebook.com";
    return (Runtime.getRuntime().exec (comando).waitFor() == 0);
}

Ping facebook or google and if you receive an answer, you have internet

    
answered by 03.01.2017 в 20:55