@Test @SmallTest @SdkSuppress(minSdkVersion = 24) public void testStartTracking_afterApi24() { mTracker.startTracking(); verify(mMockConnectivityManager) .registerDefaultNetworkCallback(any(ConnectivityManager.NetworkCallback.class)); }
@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();  }