List of usage examples for android.net ConnectivityManager getActiveNetworkInfo
@Deprecated
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
@Nullable
public NetworkInfo getActiveNetworkInfo()
From source file:Main.java
public static boolean isNetworkAvaliable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; }//ww w . j a v a2 s . c om return false; }
From source file:Main.java
public static boolean isConnAvailAndNotRoaming(Context context) { ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (conMgr.getActiveNetworkInfo() != null && conMgr.getActiveNetworkInfo().isAvailable() && conMgr.getActiveNetworkInfo().isConnected()) { if (!conMgr.getActiveNetworkInfo().isRoaming()) return true; else// w w w . j ava 2s .c o m return false; } else { Log.w(TAG, "Internet Connection NOT Present"); return false; } }
From source file:Main.java
public static boolean isNetworkOk(Context context) { ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } else {//from www.j av a 2 s.c o m Toast.makeText(context, "Network is disconnected", Toast.LENGTH_SHORT).show(); return false; } }
From source file:Main.java
public static boolean isNetworkAvailable(Context mContext) { ConnectivityManager mConnectManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); if (mConnectManager.getActiveNetworkInfo() != null && mConnectManager.getActiveNetworkInfo().isAvailable()) { return true; }//from ww w. j av a2s . c o m return false; }
From source file:Main.java
public static boolean isConnected(final Context context) { final ConnectivityManager connectManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); return connectManager.getActiveNetworkInfo().isConnected(); }
From source file:Main.java
public static boolean isOpenNetwork(Context context) { if (null == context) { return false; }//from w w w . j a va 2 s . c o m ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); } return false; }
From source file:Main.java
public static boolean isWifiConnected(final Context context) { final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected() && networkInfo.getTypeName().equalsIgnoreCase("WIFI"); }
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = (cm != null) ? cm.getActiveNetworkInfo() : null; if (info != null && info.isAvailable() && info.isConnected()) { return true; }/* w w w. j a v a 2 s .c om*/ return false; }
From source file:Main.java
public static boolean netWorkCheck(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) { return info.isConnected(); } else {// w w w. jav a 2 s . co m return false; } }
From source file:Main.java
public static boolean checkNetWork(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager.getActiveNetworkInfo() != null) { return connectivityManager.getActiveNetworkInfo().isAvailable(); }//from w ww . j a v a2 s . com return false; }