Stay organized with collections
Save and categorize content based on your preferences.
The Phone Number Hint API, a library powered by Google Play services,
provides a frictionless way to show a user's (SIM-based) phone numbers as a
hint.
The benefits to using Phone Number Hint include the following:
No additional permission requests are needed
Eliminates the need for the user to manually type in the phone number
No Google Account is needed
Not directly tied to sign-in or sign-up workflows
Wider support for Android versions compared to Autofill
How it works
The Phone Number Hint API utilizes a PendingIntent
to initiate the flow. Once the PendingIntent has been launched the user will be
presented with a UI, listing out all (SIM-based) phone numbers. The user can
then choose to select a phone number they would like to use or cancel the flow.
The selected phone number will then be made available to the developer to
retrieve from the Intent.
Figure 1. Phone Number Hint UI and Settings
To prepare your app, complete the steps in the following sections.
Call SignInClient.getPhoneNumberHintIntent(),
passing in the previous GetPhoneNumberHintIntentRequest object,
to retrieve the PendingIntent to initiate the Phone Number Hint flow.
Kotlin
valphoneNumberHintIntentResultLauncher=...Identity.getSignInClient(activity).getPhoneNumberHintIntent(request).addOnSuccessListener{result:PendingIntent->try{phoneNumberHintIntentResultLauncher.launch(IntentSenderRequest.Builder(result).build())}catch(e:Exception){Log.e(TAG,"Launching the PendingIntent failed")}}.addOnFailureListener{Log.e(TAG,"Phone Number Hint failed")}
Java
ActivityResultLauncherphoneNumberHintIntentResultLauncher=...Identity.getSignInClient(activity).getPhoneNumberHintIntent(request).addOnSuccessListener(result->{try{phoneNumberHintIntentResultLauncher.launch(result.getIntentSender());}catch(Exceptione){Log.e(TAG,"Launching the PendingIntent failed",e);}}).addOnFailureListener(e->{Log.e(TAG,"Phone Number Hint failed",e);});
valphoneNumberHintIntentResultLauncher=registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()){result->try{valphoneNumber=Identity.getSignInClient(activity).getPhoneNumberFromIntent(result.data)}catch(e:Exception){Log.e(TAG,"Phone Number Hint failed")}}
Java
ActivityResultLauncherphoneNumberHintIntentResultLauncher=registerForActivityResult(newActivityResultContracts.StartActivityForResult(),newActivityResultCallback(){@OverridepublicvoidonActivityResult(ActivityResultresult){try{StringphoneNumber=Identity.getSignInClient(activity).getPhoneNumberFromIntent(result.getData());}catch{Log.e(TAG,"Phone Number Hint failed",e);}}});
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-14 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 2025-08-14 UTC."],[],[],null,["# Phone Number Hint\n\nThe Phone Number Hint API, a library powered by [Google Play services](https://developers.google.com/android),\nprovides a frictionless way to show a user's (SIM-based) phone numbers as a\nhint.\n\nThe benefits to using Phone Number Hint include the following:\n\n- No additional permission requests are needed\n- Eliminates the need for the user to manually type in the phone number\n- No Google Account is needed\n- Not directly tied to sign-in or sign-up workflows\n- Wider support for Android versions compared to Autofill\n\nHow it works\n------------\n\nThe Phone Number Hint API utilizes a [`PendingIntent`](/reference/android/app/PendingIntent)\nto initiate the flow. Once the PendingIntent has been launched the user will be\npresented with a UI, listing out all (SIM-based) phone numbers. The user can\nthen choose to select a phone number they would like to use or cancel the flow.\nThe selected phone number will then be made available to the developer to\nretrieve from the [`Intent`](/reference/android/content/Intent).\n**Figure 1.** Phone Number Hint UI and Settings\n\nTo prepare your app, complete the steps in the following sections.\n\nConfigure your app\n------------------\n\nAdd the [Google Play services](https://developers.google.com/android)\ndependency for the Phone Number Hint API to your\n[module's Gradle build file](/studio/build#module-level),\nwhich is commonly `app/build.gradle`: \n\n apply plugin: 'com.android.application'\n\n ...\n\n dependencies {\n implementation 'com.google.android.gms:play-services-auth:21.4.0'\n }\n\n### Create a GetPhoneNumbeHintIntentRequest object\n\nStart by creating a [`GetPhoneNumberHintIntentRequest`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest) object using the\nprovided [`GetPhoneNumberHintIntentRequest.Builder()`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.Builder)\nmethod. This request object can then be used to get an `Intent` to start the\nPhone Number Hint flow. \n\n### Kotlin\n\n```kotlin\nval request: GetPhoneNumberHintIntentRequest = GetPhoneNumberHintIntentRequest.builder().build()\n```\n\n### Java\n\n```java\nGetPhoneNumberHintIntentRequest request = GetPhoneNumberHintIntentRequest.builder().build();\n```\n\n### Requesting Phone Number Hint\n\nCall [`SignInClient.getPhoneNumberHintIntent()`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/identity/SignInClient#getPhoneNumberHintIntent(com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest)),\npassing in the previous `GetPhoneNumberHintIntentRequest` object,\nto retrieve the `PendingIntent` to initiate the Phone Number Hint flow. \n\n### Kotlin\n\n```kotlin\nval phoneNumberHintIntentResultLauncher = ...\n\nIdentity.getSignInClient(activity)\n.getPhoneNumberHintIntent(request)\n.addOnSuccessListener { result: PendingIntent -\u003e\n try {\n phoneNumberHintIntentResultLauncher.launch(\n IntentSenderRequest.Builder(result).build()\n )\n } catch (e: Exception) {\n Log.e(TAG, \"Launching the PendingIntent failed\")\n }\n}\n.addOnFailureListener {\n Log.e(TAG, \"Phone Number Hint failed\")\n}\n```\n\n### Java\n\n```java\nActivityResultLauncher phoneNumberHintIntentResultLauncher = ...\n\nIdentity.getSignInClient(activity)\n .getPhoneNumberHintIntent(request)\n .addOnSuccessListener( result -\u003e {\n try {\n phoneNumberHintIntentResultLauncher.launch(result.getIntentSender());\n } catch(Exception e) {\n Log.e(TAG, \"Launching the PendingIntent failed\", e);\n }\n })\n .addOnFailureListener(e -\u003e {\n Log.e(TAG, \"Phone Number Hint failed\", e);\n });\n```\n\n### Retrieving the phone number\n\nPass in the `Intent` to [`SignInClient.getPhoneNumberFromIntent`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/identity/SignInClient#getPhoneNumberFromIntent(android.content.Intent))\nto retrieve the phone number. \n\n### Kotlin\n\n```kotlin\nval phoneNumberHintIntentResultLauncher =\nregisterForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result -\u003e\n try {\n val phoneNumber = Identity.getSignInClient(activity).getPhoneNumberFromIntent(result.data)\n } catch(e: Exception) {\n Log.e(TAG, \"Phone Number Hint failed\")\n }\n }\n```\n\n### Java\n\n```java\nActivityResultLauncher phoneNumberHintIntentResultLauncher =\n registerForActivityResult(\n new ActivityResultContracts.StartActivityForResult(),\n new ActivityResultCallback() {\n @Override\n public void onActivityResult(ActivityResult result) {\n try {\n String phoneNumber = Identity.getSignInClient(activity).getPhoneNumberFromIntent(result.getData());\n } catch {\n Log.e(TAG, \"Phone Number Hint failed\", e);\n }\n }\n });\n```"]]