Skip to content

Instantly share code, notes, and snippets.

@lethargicpanda
Created April 11, 2011 13:56
Show Gist options
  • Save lethargicpanda/913555 to your computer and use it in GitHub Desktop.
Save lethargicpanda/913555 to your computer and use it in GitHub Desktop.
Method checking the connectivity of an Android device
private static boolean checkConnectivity(Context context){
ConnectivityManager connec = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
return (connec.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment