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
private static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null; }
From source file:Main.java
public static boolean isConnectInternet(Context context) { ConnectivityManager conManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = conManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isConnectedOrConnecting(); }/*from w ww .j a va2 s. c o m*/ return false; }
From source file:Main.java
public static boolean isFastDownload(Context ctx) { ConnectivityManager mgrConn = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); return mgrConn.getActiveNetworkInfo() != null && mgrConn.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED; // TelephonyManager mgrTel = (TelephonyManager) // ctx.getSystemService(Context.TELEPHONY_SERVICE); // || mgrTel.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS) { }
From source file:Main.java
public static boolean checkMobileNET(Context cxt) { ConnectivityManager cm = (ConnectivityManager) cxt.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) return true; else//from w w w . ja va 2s. c om return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context mycontext) { ConnectivityManager connectivityManager = (ConnectivityManager) mycontext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean checkNetworkConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); final NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifi.isAvailable() || mobile.isAvailable()) return true; else/* w ww.j a v a 2s . c o m*/ return false; }
From source file:Main.java
public static boolean isConnectedToTheInternet(Context context) { final ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = connManager.getActiveNetworkInfo(); return (activeNetwork != null && activeNetwork.getState() == NetworkInfo.State.CONNECTED); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isAvailable(); }
From source file:Main.java
public static boolean isNetworkConnectet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnected(); }
From source file:Main.java
public static boolean isOnline(final Context context) { final ConnectivityManager conMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo[] networkInfos = conMgr.getAllNetworkInfo(); for (final NetworkInfo networkInfo : networkInfos) { if ((networkInfo.getState() == NetworkInfo.State.CONNECTED) || (networkInfo.getState() == NetworkInfo.State.CONNECTING)) { return true; }/* www .j a va 2 s .c o m*/ } return false; }