@Test public void getLastLocationShouldRequestLastLocationFromLocationManager() { LocationManager locationManager = Mockito.spy((LocationManager) ReflectionHelpers.getField(androidGpsLocationClient, "locationManager")); ReflectionHelpers.setField(androidGpsLocationClient, "locationManager", locationManager); Location location = new Location(LocationManager.GPS_PROVIDER); location.setAccuracy(4f); location.setAltitude(23f); location.setLatitude(3d); location.setLongitude(1d); Mockito.doReturn(location).when(locationManager).getLastKnownLocation(LocationManager.GPS_PROVIDER); Location lastLocation = androidGpsLocationClient.getLastLocation(); Assert.assertEquals(location, lastLocation); Mockito.verify(locationManager).getLastKnownLocation(LocationManager.GPS_PROVIDER); }
@SuppressLint("MissingPermission") @Nullable @Override public Location getLastLocation() { Location lastLocationFromProvider = locationManager.getLastKnownLocation(getProvider()); return lastLocationFromProvider != null && (lastLocation == null || lastLocationFromProvider.getTime() > lastLocation.getTime()) ? lastLocationFromProvider : lastLocation; }
AndroidGpsLocationClient extends BaseLocationClient { @SuppressLint("MissingPermission") @Nullable @Override public Location getLastLocation() { Location lastLocationFromProvider = locationManager.getLastKnownLocation(getProvider()); return lastLocationFromProvider != null && (lastLocation == null || lastLocationFromProvider.getTime() > lastLocation.getTime()) ? lastLocationFromProvider : lastLocation; } }
AndroidGpsLocationClient extends BaseLocationClient { @SuppressLint("MissingPermission") @Nullable @Override public Location getLastLocation() { Location lastLocationFromProvider = locationManager.getLastKnownLocation(getProvider()); return lastLocationFromProvider != null && (lastLocation == null || lastLocationFromProvider.getTime() > lastLocation.getTime()) ? lastLocationFromProvider : lastLocation; } AndroidGpsLocationClient(@NonNull Context context); }
AndroidGpsLocationClient extends BaseLocationClient { @SuppressLint("MissingPermission") @Nullable @Override public Location getLastLocation() { Location lastLocationFromProvider = locationManager.getLastKnownLocation(getProvider()); return lastLocationFromProvider != null && (lastLocation == null || lastLocationFromProvider.getTime() > lastLocation.getTime()) ? lastLocationFromProvider : lastLocation; } AndroidGpsLocationClient(@NonNull Context context); @Override void stopLocationUpdates(); @SuppressLint("MissingPermission") @Nullable @Override Location getLastLocation(); @Override void requestLocationUpdates(@NonNull LocationListener locationListener); @Override void setUpdateIntervals(long updateInterval, long fastestUpdateInterval); @NonNull @Override String getProvider(); @Override void close(); }
AndroidGpsLocationClient extends BaseLocationClient { @SuppressLint("MissingPermission") @Nullable @Override public Location getLastLocation() { Location lastLocationFromProvider = locationManager.getLastKnownLocation(getProvider()); return lastLocationFromProvider != null && (lastLocation == null || lastLocationFromProvider.getTime() > lastLocation.getTime()) ? lastLocationFromProvider : lastLocation; } AndroidGpsLocationClient(@NonNull Context context); @Override void stopLocationUpdates(); @SuppressLint("MissingPermission") @Nullable @Override Location getLastLocation(); @Override void requestLocationUpdates(@NonNull LocationListener locationListener); @Override void setUpdateIntervals(long updateInterval, long fastestUpdateInterval); @NonNull @Override String getProvider(); @Override void close();  }