Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Google Play Hizmetleri tarafından desteklenen bir kitaplık olan Telefon Numarası İpucu API'si, kullanıcının (SIM tabanlı) telefon numaralarını ipucu olarak göstermenin sorunsuz bir yolunu sunar.
Telefon numarası ipucu kullanmanın avantajları şunlardır:
Ek izin isteğinde bulunmanıza gerek yoktur.
Kullanıcının telefon numarasını manuel olarak yazması gerekmez.
Google Hesabı gerekmez
Doğrudan oturum açma veya kaydolma iş akışlarına bağlı değildir
Otomatik doldurmaya kıyasla Android sürümleri için daha geniş destek
İşleyiş şekli
Telefon Numarası İpucu API'si, akışı başlatmak için bir PendingIntent kullanır. PendingIntent başlatıldıktan sonra kullanıcıya tüm (SIM tabanlı) telefon numaralarını listeleyen bir kullanıcı arayüzü gösterilir. Kullanıcı, kullanmak istediği telefon numarasını seçebilir veya akışı iptal edebilir.
Ardından, seçilen telefon numarası geliştiricinin Intent'den alabilmesi için kullanılabilir hale getirilir.
Şekil 1. Telefon Numarası İpucu Kullanıcı Arayüzü ve Ayarları
Uygulamanızı hazırlamak için aşağıdaki bölümlerdeki adımları tamamlayın.
Telefon numarası ipucu akışını başlatmak için önceki GetPhoneNumberHintIntentRequest nesnesini ileterek PendingIntent öğesini almak üzere SignInClient.getPhoneNumberHintIntent() işlevini çağırın.
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);}}});
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-08-17 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 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```"]]