@Test @SmallTest @SdkSuppress(maxSdkVersion = 23) public void testStopTracking_beforeApi24() { mTracker.stopTracking(); verify(mMockContext).unregisterReceiver(any(BroadcastReceiver.class)); }
@Override public void stopTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Unregistering network callback"); mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Unregistering broadcast receiver"); mAppContext.unregisterReceiver(mBroadcastReceiver); } }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void stopTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Unregistering network callback"); mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Unregistering broadcast receiver"); mAppContext.unregisterReceiver(mBroadcastReceiver); } } }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void stopTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Unregistering network callback"); mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Unregistering broadcast receiver"); mAppContext.unregisterReceiver(mBroadcastReceiver); } } NetworkStateTracker(Context context); }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void stopTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Unregistering network callback"); mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Unregistering broadcast receiver"); mAppContext.unregisterReceiver(mBroadcastReceiver); } } NetworkStateTracker(Context context); @Override NetworkState getInitialState(); @Override void startTracking(); @Override void stopTracking(); }
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void stopTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Unregistering network callback"); mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Unregistering broadcast receiver"); mAppContext.unregisterReceiver(mBroadcastReceiver); } } NetworkStateTracker(Context context); @Override NetworkState getInitialState(); @Override void startTracking(); @Override void stopTracking();  }