Code example for NetworkInfo.State

Methods: equals

0
 
	public static boolean connectionPresent (final Context context) {
		final ConnectivityManager cMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		final NetworkInfo netInfo = cMgr.getActiveNetworkInfo();
		if ((netInfo != null) && (netInfo.getState() != null)) {
			return netInfo.getState().equals(State.CONNECTED);
		} 
		return false; 
	} 
 
} 
Connect your IDE to all the code out there  Get Codota for Java