ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET); if (ni != null && ni.isAvailable()) { Log.d("Test2", "ETHERNET is available"); if (ni.isConnected()) Log.d("Test2", "ETHERNET is connected"); else Log.d("Test2", "ETHERNET is not connected"); } else Log.d("Test2", "ETHERNET is not available"); ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (ni != null && ni.isAvailable()) { Log.d("Test2", "MOBILE is available"); if (ni.isConnected()) Log.d("Test2", "MOBILE is connected"); else Log.d("Test2", "MOBILE is not connected"); } else Log.d("Test2", "MOBILE is not available"); ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (ni != null && ni.isAvailable()) { Log.d("Test2", "WIFI is available"); if (ni.isConnected()) Log.d("Test2", "WIFI is connected"); else Log.d("Test2", "WIFI is not connected"); } else Log.d("Test2", "WIFI is not available"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)