List of usage examples for android.net NetworkInfo isAvailable
@Deprecated public boolean isAvailable()
From source file:Main.java
public static boolean isNetWorkAvailable(Context context) { boolean bisConnFlag = false; ConnectivityManager conManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo network = conManager.getActiveNetworkInfo(); if (network != null) { bisConnFlag = network.isAvailable(); }//ww w.j a v a 2 s .c o m return bisConnFlag; }
From source file:Main.java
/** * checkout network connect//w w w . jav a 2 s. com * * @param context * @return */ public static boolean isNetworkConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); } return false; }
From source file:Main.java
public static boolean Is3GAvailable(Context context) { ConnectivityManager m_NetConnectMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean bConnect = false; try {// w w w . jav a2 s.co m if (m_NetConnectMgr == null) return false; NetworkInfo info = m_NetConnectMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); bConnect = (info.isAvailable() && info.isConnected()); } catch (Exception e) { return false; } return bConnect; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { if (context != null) { ConnectivityManager manager = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (manager == null) { return false; }/*from w w w .ja va 2 s . c om*/ NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; } if (networkinfo.getState() == NetworkInfo.State.CONNECTED) { return true; } else { return false; } } return false; }
From source file:Main.java
public static boolean IsWifiAvailable(Context context) { ConnectivityManager m_NetConnectMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean bConnect = false; try {/*from ww w. j a va 2 s . co m*/ if (m_NetConnectMgr == null) return false; NetworkInfo info = m_NetConnectMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); bConnect = (info.isAvailable() && info.isConnected()); } catch (Exception e) { return false; } return bConnect; }
From source file:Main.java
public static boolean checkConnection(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); }//from ww w .jav a2s.c o m return false; }
From source file:Main.java
public static boolean canNetworkUseful(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (manager == null) { return false; }/*ww w . j a v a2s .c om*/ NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; } return true; }
From source file:Main.java
public static boolean checkNetwork(Context ctx) { ConnectivityManager mConnectivityManager = (ConnectivityManager) ctx .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null) return mNetworkInfo.isAvailable(); return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context mContext) { boolean result = false; try {//from w w w . j ava 2 s . c o m ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null) { result = ni.isAvailable(); } } } catch (Exception e) { } return result; }
From source file:Main.java
public static boolean checkConnection(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); }//from w ww .ja v a 2 s . c o m return false; }