Code example for NetworkInfo

Methods: getState, isRoaming

0
	 */ 
	@Override 
	public void onReceive(Context context, Intent intent) {
		if(intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
			NetworkInfo ni = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
			NetworkInfo.State state = (ni == null ? NetworkInfo.State.UNKNOWN : ni.getState());
			switch(state) {
				case CONNECTED:
					mDataConnectionIsConnected = true;
					if (ni.isRoaming())
						try { 
							mDataConnectionIsConnected = 
								(Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.DATA_ROAMING) == 1) ?
								true : false; 
						} 
						catch (SettingNotFoundException e) {
							e.printStackTrace();
						} 
					break; 
				case DISCONNECTED:
					if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false))