code: private void getNetworkInfo() {
  		// Create a listener to check for new network connections (e.g. switching from mobile to Wifi, or losing internet connection)
  		NetworkConnectionListener listener = new NetworkConnectionListener() {
  
  			@Override
  			public void networkChanged(NetworkConnectionType newConnection) {
  				Log.i("BMSCore", "New network connection: " + newConnection.toString());
  			}
  		};
  
  		// Initilize the network monitor with the application context and network change listener
  		this.networkMonitor = new NetworkMonitor(getApplicationContext(), listener);
  
  		// Start listening for network changes
  		networkMonitor.startMonitoringNetworkChanges();
  
  		// See if the device currently has internet access, and see what type of connection it is using
  		Log.i("BMSCore", "Is connected to the internet: " + networkMonitor.isInternetAccessAvailable());
  		Log.i("BMSCore", "Connection type: " + networkMonitor.getCurrentConnectionType().toString());
  
  		// Check that the user has given permissions to read the phone's state.
  		// If permission is granted, get the type of mobile data network being used.
  		int networkPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
  		if (networkPermission == PackageManager.PERMISSION_GRANTED) {
  			Log.i("BMSCore", "Mobile network type: " + networkMonitor.getMobileNetworkType());
  		}
  		else {
  			Log.i("BMSCore", "Obtaining permission to read phone state");
  			if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
  				// Asynchronously explain to the user why you are attempting to request this permission.
  				// Once this is done, try to request the permission again.
  			}
  			else {
  				ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, MY_PERMISSIONS_READ_PHONE_STATE);
  			}
  		}
  	}
docs: Exercise the NetworkMonitor API