Skip to content

Instantly share code, notes, and snippets.

@milaptank
Created February 3, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milaptank/ca1843361f6ef437cef9 to your computer and use it in GitHub Desktop.
Save milaptank/ca1843361f6ef437cef9 to your computer and use it in GitHub Desktop.
public static boolean isInternetAvailable() {
Runtime runtime = Runtime.getRuntime();
try {
Process ipProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
int exitValue = ipProcess.waitFor();
Debug.i(exitValue + "");
return (exitValue == 0);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment