Phone Number Hint API は Google Play 開発者サービスによるライブラリで、ユーザーの(SIM ベースの)電話番号をヒントとして表示する手間を省くことができます。
電話番号のヒントを使用するメリットは次のとおりです。
追加の権限リクエストは不要
ユーザーが電話番号を手動で入力する必要がなくなります
Google アカウントは不要
ログイン ワークフローまたは登録ワークフローに直接関連していない
自動入力よりも Android バージョンのサポート範囲が広い
仕組み
Phone Number Hint API は PendingIntent を使用してフローを開始します。PendingIntent が起動されると、すべての(SIM ベースの)電話番号を一覧表示する UI がユーザーに表示されます。ユーザーは、使用する電話番号を選択するか、フローをキャンセルするかを選択できます。選択した電話番号は、デベロッパーが Intent から取得できるようになります。
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);}}});
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-17 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```"]]