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 isNetworkConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return manager.getActiveNetworkInfo().isConnected(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { boolean netWorkStatus = false; ConnectivityManager connManager = (ConnectivityManager) context.getSystemService("connectivity"); if (connManager.getActiveNetworkInfo() != null) { netWorkStatus = connManager.getActiveNetworkInfo().isAvailable(); }//from www . j a v a 2s . c om return netWorkStatus; }
From source file:Main.java
public static boolean isOpenNetwork(Context con) { ConnectivityManager connManager = (ConnectivityManager) con.getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); }/*from ww w . j a v a 2 s .c o m*/ return false; }
From source file:Main.java
private static NetworkInfo getNetworkInfo(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) { return true; } else {/*from w w w. j a va 2s .co m*/ return false; } }
From source file:Main.java
public static boolean isConnected(Context pContext) { ConnectivityManager cm = (ConnectivityManager) pContext.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting(); }
From source file:Main.java
/** * Checks if there is any sort of Internet connection * @param context/*from w w w . j a v a2 s .co m*/ * the context in which to check Internet state * @return true if connected to Internet, false if not */ public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.getActiveNetworkInfo() == null) return false; return cm.getActiveNetworkInfo().isConnected(); }
From source file:Main.java
public static boolean isOnline(Activity a) { ConnectivityManager cm = (ConnectivityManager) a.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnected(); }
From source file:Main.java
public static boolean isNetworkConnected(Context ct) { ConnectivityManager cm = (ConnectivityManager) ct.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
private static NetworkInfo getNetworkInfo(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo(); }