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 isWifi(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info == null) return false; int netType = info.getType(); if (netType == ConnectivityManager.TYPE_WIFI) { return info.isConnected(); } else {/*from w w w . j ava 2 s . c om*/ return false; } }
From source file:Main.java
public static boolean isOnline(final Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return (netInfo != null) && netInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isWiFiConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return networkInfo.getType() == ConnectivityManager.TYPE_WIFI ? true : false; }
From source file:Main.java
public static boolean IsWifiConnection(Context context) { ConnectivityManager conectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = conectivityManager.getActiveNetworkInfo(); if (networkInfo == null) { return false; }/*from ww w . j av a2 s .c om*/ return networkInfo.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return wifiNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean hasNetwork(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) return false; NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo(); for (NetworkInfo networkInfo : networkInfos) { if (networkInfo != null && networkInfo.isConnected()) return true; }//from ww w .j a v a 2 s. com return false; }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = conn.getActiveNetworkInfo(); return (info != null && info.isConnected()); }
From source file:Main.java
public static boolean hasInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isAvailable() && info.isConnected(); }
From source file:Main.java
public static boolean isNetworkOk(Context context) { ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } else {/*ww w. j a v a2 s . co m*/ Toast.makeText(context, "Network is disconnected", Toast.LENGTH_SHORT).show(); return false; } }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }