Autocomplete

public final class Autocomplete


Autocomplete creates a launch intent for an activity that allows a user to start typing a place name or an address, and see place predictions appear as they type.

Users are expected to choose one of the predictions. See the developer's guide for more details.

If the user exits the autocomplete activity without choosing a place, the calling activity will receive RESULT_CANCELED. If there is an error, the calling activity will receive RESULT_ERROR.

Summary

Nested types

Builder for an intent to launch the autocomplete activity.

Public methods

static Place

Returns the Place selected by the user.

static Status

Returns the Status associated with the result.

Public methods

getPlaceFromIntent

public static Place getPlaceFromIntent(Intent intent)

Returns the Place selected by the user.

Parameters
Intent intent

The result Intent that was specified in Activity.onActivityResult.

Returns
Place

The user's selected Place.

Throws
java.lang.IllegalArgumentException

If the intent was not properly generated by the Places API.

getStatusFromIntent

public static Status getStatusFromIntent(Intent intent)

Returns the Status associated with the result.

The list of possible status codes is available at .

If the activity's result code is RESULT_ERROR, the will indicate the cause of error e.g. providing an invalid API key.

Parameters
Intent intent

The result Intent that was provided in Activity.onActivityResult.

Returns
Status

the Status of the result.

Throws
java.lang.IllegalArgumentException

If the intent was not properly generated by the Places API.