קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כדי להפעיל כניסה בלחיצה אחת למשתמשים חוזרים, אפשר להציג למשתמשים בקשה לשמור את הסיסמה שלהם ב-Google. המשתמש יוכל להיכנס לחשבון באמצעות הסיסמאות השמורות באפליקציה ובאינטרנט.
כשמתחילים את תהליך שמירת הסיסמה, מוצג למשתמש דיאלוג בתחתית המסך שמאפשר לו לבחור אם הוא רוצה לשמור את הסיסמה ובאיזה חשבון Google הוא רוצה לשמור אותה.
הפעלת תיבת דו-שיח של גיליון מידע מלמטה לשמירת סיסמה
אחרי שמאמתים את שם המשתמש והסיסמה באמצעות ה-backend, צריך להפעיל את תיבת הדו-שיח לשמירת הסיסמה. שומרים את פרטי הכניסה בזיכרון בזמן האימות. אחרי שמוודאים שפרטי הכניסה תקינים, מפעילים את תיבת הדו-שיח של השמירה באופן הבא:
יוצרים אובייקט SignInPassword חדש. צריך לאתחל אותו עם מזהה המשתמש שבו הוא משתמש בשירות שלכם (לדוגמה, שם המשתמש או כתובת האימייל) והסיסמה שרוצים לשמור.
private static final int REQUEST_CODE_GIS_SAVE_PASSWORD = 2; /* unique request id */
private void savePassword() {
SignInPassword signInPassword = new SignInPassword(userId, password);
...
מטפלים בתוצאה של תהליך שמירת הסיסמה ב-onActivityResult:
@OverridepublicvoidonActivityResult(intrequestCode,intresultCode,Intentdata){super.onActivityResult(requestCode,resultCode,data);if(requestCode==REQUEST_CODE_GIS_SAVE_PASSWORD){if(resultCode==Activity.RESULT_OK){/* password was saved */}elseif(resultCode==Activity.RESULT_CANCELED){/* password saving was cancelled */}}}
privateActivityResultLauncher<IntentSenderRequest>savePasswordHandler=registerForActivityResult(newActivityResultContracts.StartIntentSenderForResult(),result->{// handle intent result here});
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","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-07-27 (שעון UTC)."],[],[],null,["# Save passwords with Credential Saving\n\n| **Caution:** One Tap for Android is deprecated. To ensure the continued security and usability of your app, [migrate to\n| Credential Manager](/identity/sign-in/credential-manager). Credential Manager supports passkey, password, and federated identity authentication (such as Sign-in with Google), stronger security, and a more consistent user experience.\n\nTo enable One Tap sign-in for returning users, you can prompt users to save\ntheir password with Google. The user will be able to sign in with their saved\npasswords in your app and on the web.\n\nWhen you start the save password flow, the user will be presented with a\nbottomsheet dialog allowing them to choose if they want to save their password\nand to which Google Account they want to save it.\n\nLaunch password save bottomsheet dialog\n---------------------------------------\n\nYou should launch the password save dialog after you have authenticated the\nusername and password with your backend. Keep the credentials in memory while\nauthenticating. After you have confirmed the credentials are valid, launch the\nsave dialog by doing the following:\n\n1. Create a new `SignInPassword` object. It should be initialized with the user\n id they use with your service (for example their username or email address)\n and password that you want to save.\n\n private static final int REQUEST_CODE_GIS_SAVE_PASSWORD = 2; /* unique request id */\n private void savePassword() {\n SignInPassword signInPassword = new SignInPassword(userId, password);\n ...\n\n2. Create a `SavePasswordRequest` object\n\n SavePasswordRequest savePasswordRequest =\n SavePasswordRequest.builder().setSignInPassword(signInPassword).build();\n\n3. Get a `PendingIntent` to display the password save dialog from\n `Identity.getCredentialSavingClient` and launch the flow:\n\n Identity.getCredentialSavingClient(activity)\n .savePassword(savePasswordRequest)\n .addOnSuccessListener(\n result -\u003e {\n startIntentSenderForResult(\n result.getPendingIntent().getIntentSender(),\n REQUEST_CODE_GIS_SAVE_PASSWORD,\n /* fillInIntent= */ null,\n /* flagsMask= */ 0,\n /* flagsValue= */ 0,\n /* extraFlags= */ 0,\n /* options= */ null);\n })\n\nHandle password save results\n----------------------------\n\nHandle the result of the password save flow in onActivityResult: \n\n @Override\n public void onActivityResult(int requestCode, int resultCode, Intent data) {\n super.onActivityResult(requestCode, resultCode, data);\n if (requestCode == REQUEST_CODE_GIS_SAVE_PASSWORD) {\n if (resultCode == Activity.RESULT_OK) {\n /* password was saved */\n } else if (resultCode == Activity.RESULT_CANCELED) {\n /* password saving was cancelled */\n }\n }\n }\n\n**Note:** Consider using the [Activity Result API](https://developer.android.com/training/basics/intents/result) to manage Activity callbacks. \n\n private ActivityResultLauncher\u003cIntentSenderRequest\u003e savePasswordHandler =\n registerForActivityResult(new ActivityResultContracts.StartIntentSenderForResult(), result -\u003e {\n // handle intent result here\n });"]]