Skip to content

Instantly share code, notes, and snippets.

@eneim
Created February 2, 2015 02:44
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 eneim/e4e630d372f98dc27de4 to your computer and use it in GitHub Desktop.
Save eneim/e4e630d372f98dc27de4 to your computer and use it in GitHub Desktop.
Android check Internet connection
public static boolean isNetworkAvailable(Context context) {
return ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo() != null;
}
Usage
if (isNetworkAvailable(context)) {
// available network
} else {
// no network
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment