Address
Stay organized with collections
Save and categorize content based on your preferences.
Nested Class Summary
class
A class that encapsulates options for the
Address APIs.
Public Constructor Summary
Inherited Method Summary
From class java.lang.Object
Public Methods
public static void
requestUserAddress
( GoogleApiClient
googleApiClient, UserAddressRequest
request, int requestCode)
API to request an address from a user. This will invoke a dialog that allows the
user to decide if they want to select a single address to share your app, or
alternatively decline to share an address at all. The response to this request is
supplied via your Activity's onActivityResult(int, int, Intent)
callback method.
Parameters
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eAddress\u003c/code\u003e class provides APIs for accessing a user's address, allowing apps to request and receive user addresses.\u003c/p\u003e\n"],["\u003cp\u003eTo use the Address APIs, you need to add the \u003ccode\u003eAPI\u003c/code\u003e to your \u003ccode\u003eGoogleApiClient\u003c/code\u003e and use the \u003ccode\u003erequestUserAddress()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erequestUserAddress()\u003c/code\u003e prompts the user to select an address; the response is delivered to your Activity's \u003ccode\u003eonActivityResult()\u003c/code\u003e callback.\u003c/p\u003e\n"],["\u003cp\u003eThe response in \u003ccode\u003eonActivityResult()\u003c/code\u003e includes a result code (\u003ca href=\"//developer.android.com/reference/android/app/Activity.html#RESULT_OK\"\u003eRESULT_OK\u003c/a\u003e, \u003ca href=\"//developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED\"\u003eRESULT_CANCELED\u003c/a\u003e, or \u003ca href=\"/android/reference/com/google/android/gms/identity/intents/AddressConstants.ResultCodes#RESULT_ERROR\"\u003eRESULT_ERROR\u003c/a\u003e), and potentially a \u003ccode\u003eUserAddress\u003c/code\u003e or error code.\u003c/p\u003e\n"]]],["The `Address` class provides APIs to access a user's address. `requestUserAddress` prompts the user to select an address to share. Developers must add the `API` to their `GoogleApiClient`. The method `requestUserAddress` takes a `GoogleApiClient`, a `UserAddressRequest`, and a `requestCode`. The response is delivered through the `onActivityResult` callback, with `RESULT_OK`, `RESULT_CANCELED`, or `RESULT_ERROR` codes and address information or error details returned in the data intent.\n"],null,["# Address\n\npublic final class **Address** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nAPIs for accessing a user's address. Calling [requestUserAddress(GoogleApiClient, UserAddressRequest, int)](/android/reference/com/google/android/gms/identity/intents/Address#requestUserAddress(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.identity.intents.UserAddressRequest, int)) will prompt the user\nto select an address to share with your application. \n\n### Nested Class Summary\n\n|-------|---|---|---------------------------------------------------------|\n| class | [Address.AddressOptions](/android/reference/com/google/android/gms/identity/intents/Address.AddressOptions) || A class that encapsulates options for the Address APIs. |\n\n### Field Summary\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| public static final [Api](/android/reference/com/google/android/gms/common/api/Api)\\\u003c[Address.AddressOptions](/android/reference/com/google/android/gms/identity/intents/Address.AddressOptions)\\\u003e | [API](/android/reference/com/google/android/gms/identity/intents/Address#API) | Add this to your [GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) via [addApi(Api )](/android/reference/com/google/android/gms/common/api/GoogleApiClient.Builder#addApi(com.google.android.gms.common.api.Api\u003c? extends com.google.android.gms.common.api.Api.ApiOptions.NotRequiredOptions\u003e)). |\n\n### Public Constructor Summary\n\n|---|-------------------------------------------------------------------------------------------|\n| | [Address](/android/reference/com/google/android/gms/identity/intents/Address#Address())() |\n\n### Public Method Summary\n\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static void | [requestUserAddress](/android/reference/com/google/android/gms/identity/intents/Address#requestUserAddress(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.identity.intents.UserAddressRequest, int))([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) googleApiClient, [UserAddressRequest](/android/reference/com/google/android/gms/identity/intents/UserAddressRequest) request, int requestCode) API to request an address from a user. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFields\n------\n\n#### public static final [Api](/android/reference/com/google/android/gms/common/api/Api)\\\u003c[Address.AddressOptions](/android/reference/com/google/android/gms/identity/intents/Address.AddressOptions)\\\u003e\n**API**\n\nAdd this to your [GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient)\nvia [addApi(Api\n)](/android/reference/com/google/android/gms/common/api/GoogleApiClient.Builder#addApi(com.google.android.gms.common.api.Api\u003c? extends com.google.android.gms.common.api.Api.ApiOptions.NotRequiredOptions\u003e)).\n\nPublic Constructors\n-------------------\n\n#### public **Address** ()\n\nPublic Methods\n--------------\n\n#### public static void **requestUserAddress** ([GoogleApiClient](/android/reference/com/google/android/gms/common/api/GoogleApiClient) googleApiClient, [UserAddressRequest](/android/reference/com/google/android/gms/identity/intents/UserAddressRequest) request, int requestCode)\n\nAPI to request an address from a user. This will invoke a dialog that allows the\nuser to decide if they want to select a single address to share your app, or\nalternatively decline to share an address at all. The response to this request is\nsupplied via your Activity's [onActivityResult(int, int, Intent)](//developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)) callback method.\n\n- If the user selects an address to share, a response code of [RESULT_OK](//developer.android.com/reference/android/app/Activity.html#RESULT_OK) is returned. You can retrieve the [UserAddress](/android/reference/com/google/android/gms/identity/intents/model/UserAddress) from the data Intent sent to [onActivityResult(int, int, Intent)](//developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)) using the [fromIntent(android.content.Intent)](/android/reference/com/google/android/gms/identity/intents/model/UserAddress#fromIntent(android.content.Intent)) key.\n- If the user declines to share an address, a response code of [RESULT_CANCELED](//developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED) is returned.\n- If there is an error retrieving addresses for the user, for example if the user has no applicable addresses, then a response code of [RESULT_ERROR](/android/reference/com/google/android/gms/identity/intents/AddressConstants.ResultCodes#RESULT_ERROR) is returned. You can retrieve the error code from the data Intent using the [EXTRA_ERROR_CODE](/android/reference/com/google/android/gms/identity/intents/AddressConstants.Extras#EXTRA_ERROR_CODE) key. \n\n##### Parameters\n\n| googleApiClient | used to communicate with Google Play Services. This should be configured to use [API](/android/reference/com/google/android/gms/identity/intents/Address#API). Must not be null. |\n| request | used to specify what kind of addresses your app can handle. You must pass in a valid [UserAddressRequest](/android/reference/com/google/android/gms/identity/intents/UserAddressRequest) created via [build()](/android/reference/com/google/android/gms/identity/intents/UserAddressRequest.Builder#build()). |\n| requestCode | used [onActivityResult(int, int, Intent)](//developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)) to identify which request triggered that callback. |\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"]]