List of usage examples for android.net NetworkInfo isConnectedOrConnecting
@Deprecated public boolean isConnectedOrConnecting()
From source file:Main.java
public static boolean isConnectedToNetwork(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isConnectedToInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); return isConnected; }
From source file:Main.java
public static boolean haveInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = cm == null ? null : cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isUsingMobile(Context context) { ConnectivityManager cnm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cnm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean ensureWifi(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo == null || !netInfo.isConnectedOrConnecting()) return false; // always OK if we're on wifi if (netInfo.getType() == ConnectivityManager.TYPE_WIFI) return true; // check for wifi only pref if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("wifiPref", true)) { Log.d("Podax", "Not downloading because Wifi is required and not connected"); return false; }/*w w w . j ava2s . com*/ // check for 3g data turned off if (!netInfo.isConnected()) { Log.d("Podax", "Not downloading because background data is turned off"); return false; } return true; }
From source file:Main.java
/** * Permet de verifier la connexion tablette est elle en 4 G ou non * @param pContext//from w w w. j a v a 2 s . c o m * @return */ public static boolean isConnectedWithData(Context pContext) { ConnectivityManager connMgr = (ConnectivityManager) pContext.getSystemService(Context.CONNECTIVITY_SERVICE); android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); android.net.NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return mobile.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isInternetConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static Boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnectedOrConnecting()) return true; return false; }
From source file:Main.java
public static boolean hasWifiConnection(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return info != null && info.isConnectedOrConnecting(); }
From source file:Main.java
/** * Returns true if the network is available or about to become available. * * @param c Context used to get the ConnectivityManager * @return true if the network is available *//*w w w . java2 s .com*/ static public boolean isNetworkAvailable(Context c) { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }