Skip to content

Instantly share code, notes, and snippets.

@erikcox
Created May 18, 2015 15:26
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 erikcox/19239aa1a4e32e50de93 to your computer and use it in GitHub Desktop.
Save erikcox/19239aa1a4e32e50de93 to your computer and use it in GitHub Desktop.
Check for Internet availability
public boolean canConnect() {
ConnectivityManager connectivityManager = (ConnectivityManager) 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