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 context) { NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();/*from w w w .j ava2 s . c o m*/ return (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static boolean isOnline(Activity activity) { ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo().isConnectedOrConnecting(); }
From source file:Main.java
private static boolean isOnline(Context ctx) { final ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isConnected(); }
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null && networkInfo.isConnected()); }
From source file:Main.java
public static boolean isConnectedToWifi(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isAvailable(); }
From source file:Main.java
static public boolean hasNetworkAccess(Context c) { ConnectivityManager network = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = network.getActiveNetworkInfo(); return info != null && info.isConnected(); }
From source file:Main.java
public static boolean hasInternetConnection(Context c) { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); }