@Test @SmallTest @SdkSuppress(maxSdkVersion = 23) public void testStartTracking_beforeApi24() { mTracker.startTracking(); ArgumentCaptor<IntentFilter> argCaptor = ArgumentCaptor.forClass(IntentFilter.class); verify(mMockContext).registerReceiver(any(BroadcastReceiver.class), argCaptor.capture()); IntentFilter intentFilter = argCaptor.getValue(); assertThat(intentFilter.hasAction(ConnectivityManager.CONNECTIVITY_ACTION), is(true)); assertThat(intentFilter.countActions(), is(1)); }
@Override public void startTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Registering network callback"); mConnectivityManager.registerDefaultNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Registering broadcast receiver"); mAppContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void startTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Registering network callback"); mConnectivityManager.registerDefaultNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Registering broadcast receiver"); mAppContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } } }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void startTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Registering network callback"); mConnectivityManager.registerDefaultNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Registering broadcast receiver"); mAppContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } } NetworkStateTracker(Context context); }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void startTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Registering network callback"); mConnectivityManager.registerDefaultNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Registering broadcast receiver"); mAppContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } } NetworkStateTracker(Context context); @Override NetworkState getInitialState(); @Override void startTracking(); @Override void stopTracking(); }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void startTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Registering network callback"); mConnectivityManager.registerDefaultNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Registering broadcast receiver"); mAppContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } } NetworkStateTracker(Context context); @Override NetworkState getInitialState(); @Override void startTracking(); @Override void stopTracking();  }