Class ShadowGeocoder

java.lang.Object
org.robolectric.shadows.ShadowGeocoder

@Implements(android.location.Geocoder.class) public final class ShadowGeocoder extends Object
  • Constructor Details

    • ShadowGeocoder

      public ShadowGeocoder()
  • Method Details

    • isPresent

      @Implementation protected static boolean isPresent()
      Returns:
      true by default, or the value specified via setIsPresent(boolean)
    • getFromLocation

      @Implementation protected List<Address> getFromLocation(double latitude, double longitude, int maxResults) throws IOException
      Returns an empty list by default, or the last value set by setFromLocation(List)

      and are ignored by this implementation, except to check that they are in appropriate bounds. determines the maximum number of addresses to return.

      Throws:
      IOException
    • getFromLocation

      @Implementation(minSdk=33) protected void getFromLocation(double latitude, double longitude, int maxResults, Geocoder.GeocodeListener listener) throws IOException
      Sets an empty list by default, or the last value set by setFromLocation(List) in the provided listener

      latitude and longitude are ignored by this implementation, except to check that they are in appropriate bounds. maxResults determines the maximum number of addresses to return.

      Throws:
      IOException
    • getFromLocationName

      @Implementation(minSdk=33) protected void getFromLocationName(String locationName, int maxResults, Geocoder.GeocodeListener listener)
      Sets an empty list by default, or the last value set by setFromLocation(List) in the provided listener

      locationName is ignored by this implementation. maxResults determines the maximum number of addresses to return.

    • setIsPresent

      public static void setIsPresent(boolean value)
      Sets the value to be returned by Geocoder.isPresent().

      This value is reset to true for each test.

    • setFromLocation

      public void setFromLocation(List<Address> list)
      Sets the value to be returned by Geocoder.getFromLocation(double, double, int).
    • setErrorMessage

      public void setErrorMessage(@Nullable String message)
      Sets the value to be passed to Geocoder.GeocodeListener.onError(String).
    • reset

      @Resetter public static void reset()