Code example for NetworkInfo

Methods: getState

0
		//getNetworkInfo(MOBILE) returns null in xoom, so check null first 
		NetworkInfo mobile_info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		NetworkInfo wifi_info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		 
		return !( (mobile_info!=null && mobile_info.getState() == NetworkInfo.State.CONNECTED)
		|| (wifi_info!=null && wifi_info.getState() == NetworkInfo.State.CONNECTED) );
	} 
 
	 
	public void makeToast(final int resId) {
		makeToast(getResources().getString(resId));
	} 
 
	public void makeToast(final String s) {
		runOnUiThread(new Runnable() {
			@Override 
			public void run() { 
				Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
			} 
		}); 
	}