AutocompleteActivity

public class AutocompleteActivity extends AppCompatActivity implements PlaceSelectionListener


Implements a fullscreen activity that returns predictions in response to user search queries.

As the user types, the autocomplete service returns suggestions for places such as businesses, addresses and points of interest.

A com.google.android.libraries.places.api.model.Place is returned once a prediction is selected.

Summary

Constants

static final int

Result code for errors when finishing the autocomplete activity.

Public constructors

Public methods

void
onCreate(@Nullable Bundle savedInstanceState)
void
onError(Status status)

Called when an error occurs while fetching details for the selected place autocomplete prediction.

void

Called when a place is selected by the user.

Inherited Constants

From android.app.Activity
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
From android.content.ComponentCallbacks2
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
From android.content.Context
static final String
ACCESSIBILITY_SERVICE = "accessibility"
static final String
ACCOUNT_SERVICE = "account"
static final String
ACTIVITY_SERVICE = "activity"
static final String
ADVANCED_PROTECTION_SERVICE = "advanced_protection"
static final String
ALARM_SERVICE = "alarm"
static final String
AMBIENT_CONTEXT_SERVICE = "ambient_context"
static final String
APPWIDGET_SERVICE = "appwidget"
static final String
APP_FUNCTION_SERVICE = "app_function"
static final String
APP_HIBERNATION_SERVICE = "app_hibernation"
static final String
APP_INTEGRITY_SERVICE = "app_integrity"
static final String
APP_OPS_SERVICE = "appops"
static final String
APP_PREDICTION_SERVICE = "app_prediction"
static final String
APP_SEARCH_SERVICE = "app_search"
static final String
AUDIO_DEVICE_VOLUME_SERVICE = "audio_device_volume"
static final String
AUDIO_SERVICE = "audio"
static final String
BACKUP_SERVICE = "backup"
static final String
BATTERY_SERVICE = "batterymanager"
static final String
BATTERY_STATS_SERVICE = "batterystats"
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int
static final int
static final int
static final int
BIND_EXTERNAL_SERVICE = -2147483648
static final long
BIND_EXTERNAL_SERVICE_LONG = 4611686018427387904
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final String
BIOMETRIC_SERVICE = "biometric"
static final String
BLOB_STORE_SERVICE = "blob_store"
static final String
BLOCKED_NUMBERS_SERVICE = "blocked_numbers"
static final String
BLUETOOTH_SERVICE = "bluetooth"
static final String
BUGREPORT_SERVICE = "bugreport"
static final String
CAMERA_SERVICE = "camera"
static final String
CAPTIONING_SERVICE = "captioning"
static final String
CARRIER_CONFIG_SERVICE = "carrier_config"
static final String
CLIPBOARD_SERVICE = "clipboard"
static final String
CLOUDSEARCH_SERVICE = "cloudsearch"
static final String
COMPANION_DEVICE_SERVICE = "companiondevice"
static final String
CONNECTIVITY_DIAGNOSTICS_SERVICE = "connectivity_diagnostics"
static final String
CONNECTIVITY_SERVICE = "connectivity"
static final String
CONSUMER_IR_SERVICE = "consumer_ir"
static final String
CONTACT_KEYS_SERVICE = "contact_keys"
static final String
CONTENT_SUGGESTIONS_SERVICE = "content_suggestions"
static final String
CONTEXTHUB_SERVICE = "contexthub"
static final String
CONTEXTUAL_SEARCH_SERVICE = "contextual_search"
static final int
static final int
static final int
static final String
CREDENTIAL_SERVICE = "credential"
static final String
CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"
static final int
static final int
static final String
DEVICE_LOCK_SERVICE = "device_lock"
static final String
DEVICE_POLICY_SERVICE = "device_policy"
static final String
DISPLAY_HASH_SERVICE = "display_hash"
static final String
DISPLAY_SERVICE = "display"
static final String
DOMAIN_VERIFICATION_SERVICE = "domain_verification"
static final String
DOWNLOAD_SERVICE = "download"
static final String
DROPBOX_SERVICE = "dropbox"
static final String
ECM_ENHANCED_CONFIRMATION_SERVICE = "ecm_enhanced_confirmation"
static final String
ETHERNET_SERVICE = "ethernet"
static final String
EUICC_CARD_SERVICE = "euicc_card"
static final String
EUICC_SERVICE = "euicc"
static final String
FILE_INTEGRITY_SERVICE = "file_integrity"
static final String
FINGERPRINT_SERVICE = "fingerprint"
static final String
FONT_SERVICE = "font"
static final String
GAME_SERVICE = "game"
static final String
GRAMMATICAL_INFLECTION_SERVICE = "grammatical_inflection"
static final String
HARDWARE_PROPERTIES_SERVICE = "hardware_properties"
static final String
HDMI_CONTROL_SERVICE = "hdmi_control"
static final String
HEALTHCONNECT_SERVICE = "healthconnect"
static final String
INPUT_METHOD_SERVICE = "input_method"
static final String
INPUT_SERVICE = "input"
static final String
IPSEC_SERVICE = "ipsec"
static final String
JOB_SCHEDULER_SERVICE = "jobscheduler"
static final String
KEYGUARD_SERVICE = "keyguard"
static final String
KEYSTORE_SERVICE = "keystore"
static final String
LAUNCHER_APPS_SERVICE = "launcherapps"
static final String
LAYOUT_INFLATER_SERVICE = "layout_inflater"
static final String
LOCALE_SERVICE = "locale"
static final String
LOCATION_SERVICE = "location"
static final String
MEDIA_COMMUNICATION_SERVICE = "media_communication"
static final String
MEDIA_METRICS_SERVICE = "media_metrics"
static final String
MEDIA_PROJECTION_SERVICE = "media_projection"
static final String
MEDIA_ROUTER_SERVICE = "media_router"
static final String
MEDIA_SESSION_SERVICE = "media_session"
static final String
MEDIA_TRANSCODING_SERVICE = "media_transcoding"
static final String
MIDI_SERVICE = "midi"
static final int
MODE_APPEND = 32768
static final int
static final int

This field is deprecated.

static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final String
MUSIC_RECOGNITION_SERVICE = "music_recognition"
static final String
NEARBY_SERVICE = "nearby"
static final String
NETD_SERVICE = "netd"
static final String
NETWORK_SCORE_SERVICE = "network_score"

This field is deprecated.

static final String
static final String
NFC_SERVICE = "nfc"
static final String
NOTIFICATION_SERVICE = "notification"
static final String
NSD_SERVICE = "servicediscovery"
static final String
OEM_LOCK_SERVICE = "oem_lock"
static final String
ON_DEVICE_INTELLIGENCE_SERVICE = "on_device_intelligence"
static final String
OVERLAY_SERVICE = "overlay"
static final String
PEOPLE_SERVICE = "people"
static final String
PERFORMANCE_HINT_SERVICE = "performance_hint"
static final String
PERMISSION_CONTROLLER_SERVICE = "permission_controller"
static final String
PERMISSION_SERVICE = "permission"
static final String
PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"
static final String
POWER_SERVICE = "power"
static final String
PRINT_SERVICE = "print"
static final String
PROFILING_SERVICE = "profiling"
static final String
RANGING_SERVICE = "ranging"
static final String
REBOOT_READINESS_SERVICE = "reboot_readiness"
static final int
static final int
static final int
static final String
RESTRICTIONS_SERVICE = "restrictions"
static final String
ROLE_SERVICE = "role"
static final String
ROLLBACK_SERVICE = "rollback"
static final String
SAFETY_CENTER_SERVICE = "safety_center"
static final String
SEARCH_SERVICE = "search"
static final String
SEARCH_UI_SERVICE = "search_ui"
static final String
SECURE_ELEMENT_SERVICE = "secure_element"
static final String
SECURITY_STATE_SERVICE = "security_state"
static final String
SENSOR_SERVICE = "sensor"
static final String
SHARED_CONNECTIVITY_SERVICE = "shared_connectivity"
static final String
SHORTCUT_SERVICE = "shortcut"
static final String
SMARTSPACE_SERVICE = "smartspace"
static final String
STATS_MANAGER = "stats"
static final String
STATUS_BAR_SERVICE = "statusbar"
static final String
STORAGE_SERVICE = "storage"
static final String
STORAGE_STATS_SERVICE = "storagestats"
static final String
SYSTEM_CONFIG_SERVICE = "system_config"
static final String
SYSTEM_HEALTH_SERVICE = "systemhealth"
static final String
SYSTEM_UPDATE_SERVICE = "system_update"
static final String
TELECOM_SERVICE = "telecom"
static final String
TELEPHONY_IMS_SERVICE = "telephony_ims"
static final String
static final String
TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"
static final String
TETHERING_SERVICE = "tethering"
static final String
TEXT_CLASSIFICATION_SERVICE = "textclassification"
static final String
static final String
THREAD_NETWORK_SERVICE = "thread_network"
static final String
TIME_MANAGER_SERVICE = "time_manager"
static final String
static final String
TV_AD_SERVICE = "tv_ad"
static final String
TV_INPUT_SERVICE = "tv_input"
static final String
TV_INTERACTIVE_APP_SERVICE = "tv_interactive_app"
static final String
UI_MODE_SERVICE = "uimode"
static final String
UI_TRANSLATION_SERVICE = "ui_translation"
static final String
USAGE_STATS_SERVICE = "usagestats"
static final String
USB_SERVICE = "usb"
static final String
USER_SERVICE = "user"
static final String
UWB_SERVICE = "uwb"
static final String
VIBRATOR_MANAGER_SERVICE = "vibrator_manager"
static final String
VIBRATOR_SERVICE = "vibrator"

This field is deprecated.

static final String
VIRTUALIZATION_SERVICE = "virtualization"
static final String
VIRTUAL_DEVICE_SERVICE = "virtualdevice"
static final String
VPN_MANAGEMENT_SERVICE = "vpn_management"
static final String
VR_SERVICE = "vrmanager"
static final String
WALLPAPER_EFFECTS_GENERATION_SERVICE = "wallpaper_effects_generation"
static final String
WALLPAPER_SERVICE = "wallpaper"
static final String
WEARABLE_SENSING_SERVICE = "wearable_sensing"
static final String
WIFI_AWARE_SERVICE = "wifiaware"
static final String
WIFI_NL80211_SERVICE = "wifinl80211"
static final String
WIFI_P2P_SERVICE = "wifip2p"
static final String
static final String
WIFI_RTT_SERVICE = "rttmanager"

This field is deprecated.

static final String
WIFI_SCANNING_SERVICE = "wifiscanner"
static final String
WIFI_SERVICE = "wifi"
static final String
WINDOW_SERVICE = "window"

Inherited methods

From android.app.Activity
void
void
void
boolean
PendingIntent
createPendingResult(int p, Intent p1, int p2)
final void

This method is deprecated.

final void
boolean
boolean
boolean
boolean
void

This method is deprecated.

boolean
void
void
void

This method is deprecated.

void
void
void
void

This method is deprecated.

ActionBar
final Application
ComponentCaller
ComponentName
String
int
ComponentName
Scene
TransitionManager
ComponentCaller
View
FragmentManager

This method is deprecated.

ComponentCaller
Intent
Object
String
int
LayoutInflater
LoaderManager

This method is deprecated.

String
int
final MediaController
OnBackInvokedDispatcher
final Activity

This method is deprecated.

Intent
SharedPreferences
Uri
int
final SearchEvent
final SplashScreen
Object
int
final CharSequence
final int
VoiceInteractor
final int
Window
WindowManager
boolean
boolean
boolean

This method is deprecated.

boolean
final boolean

This method is deprecated.

boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final Cursor
managedQuery(Uri p, String[] p1, String p2, String[] p3, String p4)

This method is deprecated.

boolean
moveTaskToBack(boolean p)
boolean
boolean

This method is deprecated.

void
void
void
void
onApplyThemeResource(Resources.Theme p, int p1, boolean p2)
void
void

This method is deprecated.

void
boolean
void
void
CharSequence
Dialog

This method is deprecated.

void
boolean
View
boolean

This method is deprecated.

void
void
boolean
void
boolean
onKeyLongPress(int p, KeyEvent p1)
boolean
onKeyMultiple(int p, int p1, KeyEvent p2)
boolean
onKeyShortcut(int p, KeyEvent p1)
boolean
onKeyUp(int p, KeyEvent p1)
void
void
void

This method is deprecated.

boolean
boolean

This method is deprecated.

boolean
void
void
onPerformDirectAction(
    String p,
    Bundle p1,
    CancellationSignal p2,
    Consumer<Bundle> p3
)
boolean
void
void
onPrepareDialog(int p, Dialog p1)

This method is deprecated.

void
boolean
void
void
void
onProvideKeyboardShortcuts(
    List<KeyboardShortcutGroup> p,
    Menu p1,
    int p2
)
Uri
void
void
boolean
void
boolean
boolean
void
void

This method is deprecated.

void
void
ActionMode
void
void
overrideActivityTransition(int p, int p1, int p2)
void
overridePendingTransition(int p, int p1)

This method is deprecated.

void
void
void
void
void
void
boolean
final void
removeDialog(int p)

This method is deprecated.

DragAndDropPermissions
void
final void
requestPermissions(String[] p, int p1)
final void
boolean

This method is deprecated.

final boolean
final T
<T extends View> requireViewById(int p)
final void
void
void
void
final void
final void
final void
setFeatureDrawableAlpha(int p, int p1)
final void
setFeatureDrawableResource(int p, int p1)
final void
void
void
setImmersive(boolean p)
void
void
void
final void
void
final void
setProgress(int p)

This method is deprecated.

final void

This method is deprecated.

final void

This method is deprecated.

final void

This method is deprecated.

void
void
final void
setResult(int p)
final void

This method is deprecated.

void
void
setShowWhenLocked(boolean p)
void
void
setTitle(int p)
void

This method is deprecated.

boolean
setTranslucent(boolean p)
void
setTurnScreenOn(boolean p)
void
setVisible(boolean p)
final void
void
boolean
boolean
boolean
boolean
final void
showDialog(int p)

This method is deprecated.

final boolean
showDialog(int p, Bundle p1)

This method is deprecated.

void
ActionMode
void
startActivities(Intent[] p)
void
void
void
void

This method is deprecated.

boolean
void
startIntentSender(IntentSender p, Intent p1, int p2, int p3, int p4)
void
startIntentSenderFromChild(
    Activity p,
    IntentSender p1,
    int p2,
    Intent p3,
    int p4,
    int p5,
    int p6
)

This method is deprecated.

void
void
void

This method is deprecated.

boolean
void
void
startSearch(String p, boolean p1, Bundle p2, boolean p3)
void
void
void

This method is deprecated.

void
takeKeyEvents(boolean p)
void
void
void
void
void
From androidx.appcompat.app.AppCompatActivity
void
void
void
boolean
T
<T extends View> findViewById(int p)
AppCompatDelegate
ActionBarDrawerToggle.Delegate
MenuInflater
Resources
ActionBar
Intent
void
void
void
void
void
boolean
onKeyDown(int p, KeyEvent p1)
void
final boolean
boolean
onMenuOpened(int p, Menu p1)
void
void
onPanelClosed(int p, Menu p1)
void
void
void
void
void
void
void
void

This method is deprecated.

boolean
void
ActionMode
void
void
void
void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
setTheme(int p)
ActionMode
void

This method is deprecated.

void
boolean
boolean
From androidx.activity.ComponentActivity
void
final void
final void
final void
final void
final void
final void
final void
final ActivityResultRegistry
CreationExtras
ViewModelProvider.Factory
FullyDrawnReporter
Object

This method is deprecated.

Lifecycle
final OnBackPressedDispatcher
final SavedStateRegistry
ViewModelStore
void
void
void

This method is deprecated.

boolean
onCreatePanelMenu(int featureId, Menu menu)
void
onMultiWindowModeChanged(boolean isInMultiWindowMode)

This method is deprecated.

void
void
onPictureInPictureModeChanged(boolean isInPictureInPictureMode)

This method is deprecated.

boolean
onPreparePanel(int featureId, View view, Menu menu)
Object

This method is deprecated.

final Object
void
void
onTrimMemory(int level)
void
Context
final ActivityResultLauncher<I>
<I, O> registerForActivityResult(
    ActivityResultContract<I, O> contract,
    ActivityResultRegistry registry,
    ActivityResultCallback<O> callback
)
void
final void
final void
final void
final void
final void
final void
final void
void
void
startActivityForResult(Intent intent, int requestCode)

This method is deprecated.

void
startIntentSenderForResult(
    IntentSender intent,
    int requestCode,
    Intent fillInIntent,
    int flagsMask,
    int flagsValues,
    int extraFlags
)

This method is deprecated.

From android.content.Context
final int
getColor(int p)
final ColorStateList
final Drawable
getDrawable(int p)
final String
getString(int p)
final T
final CharSequence
getText(int p)
final TypedArray
void
void
sendBroadcastMultiplePermissions(
    Intent p,
    String[] p1,
    BroadcastOptions p2
)
void
From android.view.ContextThemeWrapper
From android.content.ContextWrapper
boolean
bindIsolatedService(
    Intent p,
    int p1,
    String p2,
    Executor p3,
    ServiceConnection p4
)
boolean
bindService(
    Intent p,
    Context.BindServiceFlags p1,
    Executor p2,
    ServiceConnection p3
)
boolean
bindServiceAsUser(
    Intent p,
    ServiceConnection p1,
    Context.BindServiceFlags p2,
    UserHandle p3
)
int
int
int[]
int
int
int[]
int
checkContentUriPermissionFull(Uri p, int p1, int p2, int p3)
int
checkPermission(String p, int p1, int p2)
int
int
checkUriPermission(Uri p, int p1, int p2, int p3)
int[]
checkUriPermissions(List<Uri> p, int p1, int p2, int p3)
void

This method is deprecated.

Context
Context
Context
Context
Context
Context
Context
Context
Context
Context
Context
Context
createWindowContext(Display p, int p1, Bundle p2)
String[]
boolean
boolean
boolean
void
void
void
void
void
enforcePermission(String p, int p1, int p2, String p3)
void
enforceUriPermission(Uri p, int p1, int p2, int p3, String p4)
String[]
Context
ApplicationInfo
AttributionSource
String
Context
File
ClassLoader
File
ContentResolver
File
File
int
File
getDir(String p, int p1)
Display
File
File[]
File
File[]
File[]

This method is deprecated.

File
File
Executor
Looper
File
File
File[]
String
String
PackageManager
String
String
ContextParams
File
SharedPreferences
String
Drawable

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
grantUriPermission(String p, Uri p1, int p2)
boolean
boolean
boolean
boolean
boolean
boolean
FileInputStream
FileOutputStream
openFileOutput(String p, int p1)
SQLiteDatabase
Drawable

This method is deprecated.

void
Intent
Intent
registerReceiverForAllUsers(
    BroadcastReceiver p,
    IntentFilter p1,
    String p2,
    Handler p3
)
void

This method is deprecated.

void

This method is deprecated.

void
void
revokeUriPermission(Uri p, int p1)
void
void
void
sendOrderedBroadcast(
    Intent p,
    int p1,
    String p2,
    String p3,
    BroadcastReceiver p4,
    Handler p5,
    String p6,
    Bundle p7,
    Bundle p8
)
void
sendOrderedBroadcastAsUser(
    Intent p,
    UserHandle p1,
    String p2,
    BroadcastReceiver p3,
    Handler p4,
    int p5,
    String p6,
    Bundle p7
)
void
sendOrderedBroadcastMultiplePermissions(
    Intent p,
    String[] p1,
    String p2,
    BroadcastReceiver p3,
    Handler p4,
    int p5,
    String p6,
    Bundle p7,
    Bundle p8
)
void

This method is deprecated.

void

This method is deprecated.

void
sendStickyOrderedBroadcast(
    Intent p,
    BroadcastReceiver p1,
    Handler p2,
    int p3,
    String p4,
    Bundle p5
)

This method is deprecated.

void
sendStickyOrderedBroadcastAsUser(
    Intent p,
    UserHandle p1,
    BroadcastReceiver p2,
    Handler p3,
    int p4,
    String p5,
    Bundle p6
)

This method is deprecated.

void

This method is deprecated.

ComponentName
boolean
ComponentName
boolean
void
void
void
void
updateServiceGroup(ServiceConnection p, int p1, int p2)
From androidx.fragment.app.FragmentActivity
void
dump(
    @NonNull String prefix,
    @Nullable FileDescriptor fd,
    @NonNull PrintWriter writer,
    @Nullable String[] args
)
@NonNull FragmentManager
@NonNull LoaderManager

This method is deprecated.

void
onActivityResult(int requestCode, int resultCode, @Nullable Intent data)

This method is deprecated.

void

This method is deprecated.

@Nullable View
onCreateView(
    @Nullable View parent,
    @NonNull String name,
    @NonNull Context context,
    @NonNull AttributeSet attrs
)
void
void
onRequestPermissionsResult(
    int requestCode,
    @NonNull String[] permissions,
    @NonNull int[] grantResults
)

This method is deprecated.

void
void
void

This method is deprecated.

void
void
void
startActivityFromFragment(
    @NonNull Fragment fragment,
    @NonNull Intent intent,
    int requestCode
)
void
startIntentSenderFromFragment(
    @NonNull Fragment fragment,
    @NonNull IntentSender intent,
    int requestCode,
    @Nullable Intent fillInIntent,
    int flagsMask,
    int flagsValues,
    int extraFlags,
    @Nullable Bundle options
)

This method is deprecated.

void
void
void
final void

This method is deprecated.

From androidx.core.app.ComponentActivity
boolean
T
<T extends SupportActivity.ExtraData> getExtraData(Class<T> extraDataClass)

This method is deprecated.

void

This method is deprecated.

final boolean
shouldDumpInternalState(String[] args)
boolean
From android.view.Window.Callback
void

Constants

RESULT_ERROR

public static final int RESULT_ERROR = 2

Result code for errors when finishing the autocomplete activity.

Public constructors

AutocompleteActivity

public AutocompleteActivity()

Public methods

onCreate

public void onCreate(@Nullable Bundle savedInstanceState)

onError

public void onError(Status status)

Called when an error occurs while fetching details for the selected place autocomplete prediction.

The list of possible status codes is available at PlacesStatusCodes. Errors returned are developer errors such as providing an invalid API key. Other errors such as network or timeout errors are handled by the widget.

onPlaceSelected

public void onPlaceSelected(Place place)

Called when a place is selected by the user.