AutocompletePrediction

public abstract class AutocompletePrediction implements Parcelable


Represents an autocomplete suggestion of a place, based on a particular text query.

An AutocompletePrediction includes the description of the suggested place as well as basic details including place ID and types.

Summary

Nested types

public abstract class AutocompletePrediction.Builder

Builder for AutocompletePrediction.

Public constructors

Public methods

static AutocompletePrediction.Builder
builder(String placeId)

Returns a Builder.

abstract @Nullable Integer

Returns the straight-line distance between the place being referred to by getPlaceId and the origin specified in the request.

SpannableString

The full text of a place.

abstract String

Returns the place ID of the place being referred to by this prediction.

abstract List<Place.Type>

This method is deprecated.

Use getTypes instead.

SpannableString

Returns the primary text of a place.

SpannableString

Returns the secondary text of a place.

abstract List<String>

Returns the list of place types associated with the place referred to by getPlaceId.

Inherited Constants

From android.os.Parcelable
static final int
static final int
static final int
static final int

Inherited methods

From android.os.Parcelable
abstract int
int
abstract void
writeToParcel(Parcel p, int p1)

Public constructors

AutocompletePrediction

public AutocompletePrediction()

Public methods

builder

public static AutocompletePrediction.Builder builder(String placeId)

Returns a Builder.

Any values, besides placeId, that are not explicitly set, default to an empty String or List.

getDistanceMeters

public abstract @Nullable Integer getDistanceMeters()

Returns the straight-line distance between the place being referred to by getPlaceId and the origin specified in the request.

Will return null if the request did not include an origin, or if the predicted place is of a certain type, such as route. See more details about the distance_meters result field.

getFullText

public SpannableString getFullText(@Nullable CharacterStyle matchStyle)

The full text of a place. This is a combination of the primary text and the secondary text.

Example: "Eiffel Tower, Avenue Anatole France, Paris, France"

If you do not wish to highlight matches, you can pass null.

getPlaceId

public abstract String getPlaceId()

Returns the place ID of the place being referred to by this prediction. For more information on place IDs, see the place ID overview.

getPlaceTypes

public abstract List<Place.TypegetPlaceTypes()

Returns the list of place types associated with the place referred to by getPlaceId. For more information on place types, see the place types overview.

This list should not be modified.

getPrimaryText

public SpannableString getPrimaryText(@Nullable CharacterStyle matchStyle)

Returns the primary text of a place. This will usually be the name of the place.

Example: "Eiffel Tower", "123 Pitt Street"

See getFullText for more information on formatting.

getSecondaryText

public SpannableString getSecondaryText(@Nullable CharacterStyle matchStyle)

Returns the secondary text of a place. This provides extra context on the place, and can be used as a second line when showing autocomplete predictions.

Example: "Avenue Anatole France, Paris, France", "Sydney, New South Wales"

See getFullText for more information on formatting.

getTypes

public abstract List<StringgetTypes()

Returns the list of place types associated with the place referred to by getPlaceId. For more information on place types, see the place types overview.

This list should not be modified.