List of usage examples for android.content Context CONNECTIVITY_SERVICE
String CONNECTIVITY_SERVICE
To view the source code for android.content Context CONNECTIVITY_SERVICE.
Click Source Link
From source file:Main.java
public static boolean checkNetwork(Context context) { ConnectivityManager netManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = netManager.getActiveNetworkInfo(); if (info != null) return info.isAvailable(); else/* w w w. j a v a2 s. c o m*/ return false; }
From source file:Main.java
public static boolean isOpenNetwork(Activity activity) { ConnectivityManager connManager = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); }//from w ww.ja v a2 s.c o m return false; }
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 hasConnected(Context context) { ConnectivityManager connectMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mobNetInfo = connectMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo wifiNetInfo = connectMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if ((mobNetInfo == null || !mobNetInfo.isConnected()) && (wifiNetInfo == null || !wifiNetInfo.isConnected())) { return false; }/*w ww .ja va2 s . c om*/ return true; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return wifiInfo.isConnected(); }
From source file:Main.java
public static boolean verifyConnection(Context context) { boolean isConnected; ConnectivityManager conectivtyManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); isConnected = conectivtyManager.getActiveNetworkInfo() != null && conectivtyManager.getActiveNetworkInfo().isAvailable() && conectivtyManager.getActiveNetworkInfo().isConnected(); return isConnected; }
From source file:Main.java
public static boolean is3G(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) { return true; }/*from ww w . ja va 2s. c o m*/ return false; }
From source file:Main.java
public static boolean isWifi(Context mContext) { ConnectivityManager connectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.getTypeName().equals("WIFI")) { return true; }/*from w w w . j a v a 2 s .co m*/ return false; }
From source file:Main.java
private static boolean hasInternet(Context context) { boolean flag = false; ConnectivityManager connectionManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectionManager.getActiveNetworkInfo() != null) { flag = connectionManager.getActiveNetworkInfo().isAvailable(); }/*from www . j a va2s . c om*/ return flag; }
From source file:Main.java
public static boolean isWifiAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return wifiNetworkInfo.isAvailable(); }