Autocomplete

public final class Autocomplete extends Object

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 Activity.RESULT_CANCELED. If there is an error, the calling activity will receive AutocompleteActivity.RESULT_ERROR.

Nested Class Summary

class Autocomplete.IntentBuilder Builder for an intent to launch the autocomplete activity. 

Public Method Summary

static Place
getPlaceFromIntent(Intent intent)
Returns the Place selected by the user.
static Status
getStatusFromIntent(Intent intent)
Returns the Status associated with the result.

Inherited Method Summary

Public Methods

public static Place getPlaceFromIntent (Intent intent)

Returns the Place selected by the user.

Parameters
intent The result Intent that was specified in Activity.onActivityResult.
Returns
  • The user's selected Place.
Throws
IllegalArgumentException If the intent was not properly generated by the Places API.

public static Status getStatusFromIntent (Intent intent)

Returns the Status associated with the result.

The list of possible status codes is available at PlacesStatusCodes.

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

Parameters
intent The result Intent that was provided in Activity.onActivityResult.
Returns
Throws
IllegalArgumentException If the intent was not properly generated by the Places API.