Code example for ConnectivityManager

Methods: getNetworkInfo

0
 
		if (DEBUG)
			Log.i(TAG, "Testing WiFi status");
 
		// First test wifi for status! 
		NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		if (netInfo != null && netInfo.isConnectedOrConnecting()) {
			if (DEBUG)
				Log.i(TAG, "WiFi detected, connecting");
			return true; 
		} 
 
		if (DEBUG)
			Log.i(TAG, "No WiFi detected, trying mobile");
 
		netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		if (netInfo != null && netInfo.isConnectedOrConnecting()) {
			if (DEBUG)
				Log.i(TAG, "Mobile detected, connecting");
			return true; 
		}