List of usage examples for android.net NetworkInfo isAvailable
@Deprecated public boolean isAvailable()
From source file:Main.java
public static boolean isNetworkConnected(Context context) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null) { return mNetworkInfo.isAvailable(); }/*from ww w. j av a 2 s. c o m*/ return false; }
From source file:Main.java
public static boolean isNetworkConncected(Context context) { ConnectivityManager connectiveManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectiveManager == null) { return false; }/* w w w . j a v a 2 s . co m*/ NetworkInfo networkInfo = connectiveManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); } return false; }
From source file:Main.java
public static Boolean isNetworkReachable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo current = cm.getActiveNetworkInfo(); if (current == null) { return false; }//from ww w. j a v a2 s . co m return (current.isAvailable()); }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { if (context != null) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); }// w ww .j ava2 s . co m } return false; }
From source file:Main.java
public static int getConnectedType(Context context) { if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null && mNetworkInfo.isAvailable()) { return mNetworkInfo.getType(); }/*www . j ava 2s .co m*/ } return -1; }
From source file:Main.java
public static final boolean hasWifiConnection(Context context) { final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return (networkInfo != null && networkInfo.isAvailable()); }
From source file:Main.java
public static int availableCommunication(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean isWifiAvail = ni.isAvailable(); boolean isWifiConn = ni.isConnected(); ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); boolean isMobileAvail = ni.isAvailable(); boolean isMobileConn = ni.isConnected(); String status = "WiFi\nAvail = " + isWifiAvail + "\nConn = " + isWifiConn + "\nMobile\nAvail = " + isMobileAvail + "\nConn = " + isMobileConn + "\n"; Log.d("Communication State! ", status); if (isWifiAvail == true && isWifiConn == true) { return ConnectivityManager.TYPE_WIFI; } else if (isMobileAvail == true && isMobileConn == true) { return ConnectivityManager.TYPE_MOBILE; } else {//from w w w . j av a 2s .co m return -1; } }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { if (context != null) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); }// w w w .j a v a2 s . co m } return false; }
From source file:Main.java
public static Boolean checkNetworkConnect(Context context) { if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null) { return mNetworkInfo.isAvailable(); }//from ww w .j av a 2 s. co m } return false; }
From source file:Main.java
/** * Check for wifi internet connectivity//from ww w .j a va 2s . c om * * @param context context * @return hasInternet boolean */ public static boolean hasWifiInternetAccess(@NonNull Context context) { try { boolean hasWifiInternet = false; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); NetworkInfo wifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi != null && wifi.isAvailable() && networkInfo != null && networkInfo.isConnectedOrConnecting()) { hasWifiInternet = true; } return hasWifiInternet; } catch (Exception e) { return false; } }