Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2017 19:16
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Android: Check networking
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
Log.d("MIAPP", "Estás online");
Log.d("MIAPP", " Estado actual: " + networkInfo.getState());
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
// Estas conectado a un Wi-Fi
Log.d("MIAPP", " Nombre red Wi-Fi: " + networkInfo.getExtraInfo());
} else {
Log.d("MIAPP", "Estás offline");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment