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 isMobile(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null) && (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE); }
From source file:Main.java
public static boolean isConnectedRoaming(Context context) { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mobile = connec.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mobile != null && mobile.isConnected() && mobile.isRoaming()) { return true; } else {//from w w w . j a v a 2 s. c o m return false; } }
From source file:Main.java
public static final boolean isNetworkAvailable(final Context context) { final ConnectivityManager connectivityManager = ((ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE)); return connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isConnected(); }
From source file:Main.java
/** * @param context//from ww w . j a va2 s .co m * @return */ public static String getNetWorkName(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) return "MOBILE"; NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) return info.getTypeName(); else return "MOBILE"; }
From source file:Main.java
public static boolean isConnectedToWifi(Context context) { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi != null && wifi.isConnected()) { return true; } else {//from www.ja v a 2 s . co m return false; } }
From source file:Main.java
public static int isNetworkAvailable(Activity act) { ConnectivityManager connectivityManager = (ConnectivityManager) act .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) return 1; else//from w ww. j a v a 2 s. co m return 0; }
From source file:Main.java
public static boolean isWifiAvailable(Context context) { ConnectivityManager mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean flag = false; if ((mWifi != null) && ((mWifi.isAvailable()))) { if ((mWifi.isConnected())) { flag = true;/*from w w w . j ava2 s. co m*/ } } return flag; }
From source file:Main.java
public static Boolean isNetworkConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (manager == null) { return false; }/* w w w . j a va 2 s .co m*/ NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; } return true; }
From source file:Main.java
public static boolean isInternetConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) return false; boolean is_connect = false; NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) { if (info.isConnected()) is_connect = true;//from w w w .j a va2 s .c o m } return is_connect; }
From source file:Main.java
public static boolean isNetConnected() { ConnectivityManager connectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getActiveNetworkInfo(); if (info != null && info.isConnected()) { return true; }/* ww w .ja v a2 s. c o m*/ return false; }