Skip to content

Instantly share code, notes, and snippets.

@yenliangl
Created December 6, 2011 09:14
Show Gist options
  • Save yenliangl/1437498 to your computer and use it in GitHub Desktop.
Save yenliangl/1437498 to your computer and use it in GitHub Desktop.
Detecting WiFi
private static boolean isConnected(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = null;
if (connectivityManager != null) {
networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
}
return networkInfo == null ? false : networkInfo.isConnected();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment