Kimlik Bilgisi Yöneticisi'ni otomatik doldurma özelliğiyle entegre etme
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Android 15 Beta 2'den itibaren androidx.credentials:1.5.0-alpha01 ile eşleştirilen geliştiriciler, kullanıcı adı veya şifre alanları gibi belirli görünümleri Kimlik Bilgisi Yöneticisi istekleriyle bağlayabilir. Kullanıcı bu görünümlerden birine odaklandığında ilgili istek, Credential Manager'a gönderilir. Elde edilen kimlik bilgileri sağlayıcılar arasında toplanır ve klavyedeki satır içi öneriler veya açılır liste önerileri gibi otomatik doldurma kullanıcı arayüzlerinde gösterilir.
Bu özellik, kullanıcılar yanlışlıkla kimlik bilgisi yöneticisi hesap seçiciyi kapattıktan sonra ilgili alanlara dokunduklarında yedek olarak kullanılabilir.
Jetpack androidx.credentials kitaplığı, geliştiricilerin bu özellik için kullanması gereken tercih edilen uç noktadır.
Şekil 1: Şifre, geçiş anahtarı ve Google ile oturum açma kullanılarak kimlik bilgileriyle otomatik doldurma sonuçları.
Uygulama
Otomatik doldurma sonuçlarında kimlik bilgilerini göstermek için Kimlik Bilgisi Yöneticisi'ni kullanmak üzere GetCredentialRequest oluşturmak için standart uygulamayı kullanın ve ardından bunu ilgili görünümlere ayarlayın. Yanıtın getCredential API çağrısından veya PendingGetCredentialRequest'den gelmesi, yanıt işleme açısından fark etmez. Aşağıdaki örnekte gösterildiği gibi, yanıt işleme aynıdır.
Öncelikle bir GetCredentialRequest oluşturun:
// Retrieves the user's saved password for your app.valgetPasswordOption=GetPasswordOption()// Get a passkey from the user's public key credential provider.valgetPublicKeyCredentialOption=GetPublicKeyCredentialOption(requestJson=requestJson)valgetCredRequest=GetCredentialRequest(listOf(getPasswordOption,getPublicKeyCredentialOption))
Ardından getCredential API'sini çağırın. Bu işlem, kimlik bilgisi yöneticisi seçiciyi gösterir.
coroutineScope{try{valresult=credentialManager.getCredential(context=activityContext,// Use an activity-based context.request=getCredRequest)handleSignIn(result)}catch(e:GetCredentialException){handleFailure(e)}}
Son olarak, otomatik doldurma deneyimini etkinleştirin. Kullanıcı bu görünümlerle etkileşimde bulunduğunda otomatik doldurmada kimlik bilgisi sonuçlarını etkinleştirmek için getCredRequest öğesini alakalı görünümlere (ör. username, password) ayarlayın.
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-27 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-27 UTC."],[],[],null,["Starting with Android 15 Beta 2, paired with\n[androidx.credentials:1.5.0-alpha01](/jetpack/androidx/releases/credentials#version_15_2), developers can link specific views like\nusername or password fields with Credential Manager requests. When the user\nfocuses on one of these views, the corresponding request is sent to Credential\nManager. The resulting credentials are aggregated across providers and displayed\nin autofill UIs, such as keyboard inline suggestions, or drop-down suggestions.\nThis feature can be used as a fallback when users accidentally dismiss the\nCredential Manager account selector and then tap on the relevant fields.\n\nThe ***Jetpack androidx.credentials*** library is the preferred endpoint for\ndevelopers to use for this feature.\n\n\u003cbr /\u003e\n\n\n**Figure 1:** Autofill results with credentials using password, passkey, and\nSign in with Google.\n| **Note:** This feature is only available for `View` objects at this time.\n\nImplementation\n\nTo use Credential Manager to show credentials in autofill results, use the\n[standard implementation](/identity/sign-in/credential-manager) to build a `GetCredentialRequest` and then set it\nto the relevant views. The response handling is the same, whether the response\ncomes from the `getCredential` API call or the `PendingGetCredentialRequest`, as\nshown in the following example.\n\nFirst, construct a `GetCredentialRequest`: \n\n // Retrieves the user's saved password for your app.\n val getPasswordOption = GetPasswordOption()\n\n // Get a passkey from the user's public key credential provider.\n val getPublicKeyCredentialOption = GetPublicKeyCredentialOption(\n requestJson = requestJson\n )\n\n val getCredRequest = GetCredentialRequest(\n listOf(getPasswordOption, getPublicKeyCredentialOption)\n )\n\nNext, call the `getCredential` API. This displays the Credential Manager\nselector. \n\n coroutineScope {\n try {\n val result = credentialManager.getCredential(\n context = activityContext, // Use an activity-based context.\n request = getCredRequest\n )\n handleSignIn(result)\n } catch (e: GetCredentialException) {\n handleFailure(e)\n }\n }\n\nFinally, enable the autofill experience. Set the `getCredRequest` to relevant\nviews (such as `username, password`) to enable credential results in autofill\nwhen the user interacts with these views.\n**Note:** The `setPendingGetCredentialRequest` is an *extension API* in the androidx.credentials library, and is called differently between Kotlin and Java. \n\n usernameEditText.pendingGetCredentialRequest = PendingGetCredentialRequest(\n getCredRequest\n ) { response -\u003e\n handleSignIn(response)\n }\n\n passwordEditText.pendingGetCredentialRequest = PendingGetCredentialRequest(\n getCredRequest\n ) { response -\u003e\n handleSignIn(response)\n }"]]