Created
February 2, 2015 02:44
-
-
Save eneim/e4e630d372f98dc27de4 to your computer and use it in GitHub Desktop.
Android check Internet connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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