Skip to content

Instantly share code, notes, and snippets.



Created Sep 4, 2017
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
You can’t perform that action at this time.