Skip to content

Instantly share code, notes, and snippets.

@ruan65
Created August 2, 2016 07:33
Show Gist options
  • Save ruan65/1d17a2aedc78c81642427f9475252fcb to your computer and use it in GitHub Desktop.
Save ruan65/1d17a2aedc78c81642427f9475252fcb to your computer and use it in GitHub Desktop.
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivityManager
= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment