تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
قد يتعذّر تنفيذ طلبات استرداد بيانات اعتماد المستخدم إذا لم يحفظ المستخدم بعد
بيانات الاعتماد أو في حال لم يشترك المستخدم في تطبيقك بعد. في هذه
يمكنك استخدام Credentials API لاسترداد تلميحات تسجيل الدخول، مثل
اسم المستخدم وعنوان بريده الإلكتروني. استخدِم هذه النصائح لملء معلومات تسجيل الدخول إلى تطبيقك مسبقًا.
ونماذج الاشتراك، لتسريع عملية إعداد التطبيق
على نظام التشغيل Android 6.0 (Marshmallow) والإصدارات الأحدث، لا يحتاج التطبيق إلى طلب
أذونات أي جهاز أو بيئة تشغيل لاسترداد تلميحات تسجيل الدخول باستخدام
Credentials API:
لاسترداد تلميحات تسجيل الدخول، عليك أولاً ضبط مربع حوار أداة اختيار التلميحات من خلال
جارٍ إنشاء HintRequest
الخاص بك. مرِّر بعد ذلك الكائن HintRequest إلى
CredentialsClient.getHintPickerIntent()
بغرض مطالبة المستخدم باختيار عنوان بريد إلكتروني أخيرًا، ابدأ
النية بالشراء من خلال startIntentSenderForResult().
سيُطلب من المستخدم اختيار عنوان بريد إلكتروني لاستخدامه.
بعد ذلك، في طريقة onActivityResult() الخاصة بالنشاط، استرجع التلميحات من
حزمة Credential.EXTRA_KEY، يُرجى التحقّق مما إذا كان المستخدم مدرَجًا في قاعدة بيانات المستخدم.
وبدء النشاط المناسب بتلميح بيانات الاعتماد.
@OverridepublicvoidonActivityResult(intrequestCode,intresultCode,Intentdata){super.onActivityResult(requestCode,resultCode,data);if(requestCode==RC_HINT){if(resultCode==RESULT_OK){Credentialcredential=data.getParcelableExtra(Credential.EXTRA_KEY);Intentintent;//CheckfortheuserIDinyouruserdatabase.if(userDatabaseContains(credential.getId())){intent=newIntent(this,SignInActivity.class);}else{intent=newIntent(this,SignUpNewUserActivity.class);}intent.putExtra("com.mycompany.myapp.SIGNIN_HINTS",credential);startActivity(intent);}else{Log.e(TAG,"Hint Read: NOT OK");Toast.makeText(this,"Hint Read Failed",Toast.LENGTH_SHORT).show();}}...}
ملء نموذج تسجيل الدخول مسبقًا
إذا كان المستخدم مُدرجًا في قاعدة بيانات المستخدمين وبدأت عملية تسجيل الدخول إلى تطبيقك
يمكنك (اختياريًا) التحقّق مما إذا كان العنصر Credential يحتوي على رقم تعريف
الرمز المميز. إذا كان الأمر كذلك، يمكنك تسجيل دخول المستخدم باستخدام الرمز المميز للمعرّف،
دون مطالبة المستخدم بكتابة كلمة مرور.
إذا لم يكن الكائن Credential يحتوي على رمز مميز للمعرّف (أو كنت لا تريد استخدامه
الرمز المميز للمعرّف)، واملأ مسبقًا حقول تسجيل الدخول بالتلميحات التي أضفتها إلى
والنية.
إذا لم يكُن المستخدم مدرَجًا في قاعدة بيانات المستخدمين وبدأت عملية الاشتراك في تطبيقك
فاملأ حقول الاشتراك مسبقًا بتلميحات تسجيل الدخول التي أضفتها إلى
النية.
يمكنك اختياريًا التحقّق ممّا إذا كان العنصر Credential يحتوي على
الرمز المميّز للمعرّف الذي يتضمّن
عنوان بريد إلكتروني أثبت ملكيته. إذا كان الأمر كذلك، يمكنك تخطي خطوة التحقق من عنوان البريد الإلكتروني في تطبيقك،
لأنّه سبق أن تحقّقت Google من عنوان البريد الإلكتروني.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-25 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eSmart Lock for Passwords is deprecated; migrate to Credential Manager for enhanced security and user experience with passkeys, passwords, and federated identities.\u003c/p\u003e\n"],["\u003cp\u003eUse the Credentials API to retrieve sign-in hints (like name and email) to pre-fill forms, streamlining user onboarding, especially when credentials are not yet saved.\u003c/p\u003e\n"],["\u003cp\u003eAndroid 6.0 (Marshmallow) and newer do not require any special permissions to retrieve sign-in hints with the Credentials API.\u003c/p\u003e\n"],["\u003cp\u003eRetrieve sign-in hints by configuring a HintRequest, launching a picker intent, and handling the result in \u003ccode\u003eonActivityResult()\u003c/code\u003e to pre-fill sign-in or sign-up forms based on user status.\u003c/p\u003e\n"],["\u003cp\u003eConsider using ID tokens for automatic sign-in or bypassing email verification if available within the retrieved Credential object.\u003c/p\u003e\n"]]],[],null,["# Provide sign-in hints to a user\n\n| **Deprecated:** Smart Lock for Passwords is deprecated. To ensure the continued security and usability of your app, [migrate to\n| Credential Manager](https://developer.android.com/training/sign-in/passkeys/) today. Credential Manager supports passkey, password, and federated identity authentication (such as Sign-in with Google), stronger security, and a more consistent user experience.\n\nRequests to retrieve user credentials can fail when a user has not yet saved\ncredentials or when a user has not yet signed up to your app. In these\nsituations, use the Credentials API to retrieve sign-in hints, such as the\nuser's name and email address. Use these hints to pre-fill your app's sign-in\nand sign-up forms, speeding up your app's on-boarding process.\n\nOn Android 6.0 (Marshmallow) and newer, your app does not need to request\nany device or runtime permissions to retrieve sign-in hints with the\nCredentials API.\n\nBefore you begin\n----------------\n\n[Configure an Android Studio project](/identity/smartlock-passwords/android/get-started).\n\nRetrieve sign-in hints\n----------------------\n\nTo retrieve the sign-in hints, first configure the hint selector dialog by\ncreating a [`HintRequest`](/android/reference/com/google/android/gms/auth/api/credentials/HintRequest.Builder)\nobject. Then, pass the `HintRequest` object to\n[`CredentialsClient.getHintPickerIntent()`](/android/reference/com/google/android/gms/auth/api/credentials/CredentialsClient#getHintPickerIntent(com.google.android.gms.auth.api.credentials.HintRequest))\nto get an intent to prompt the user to choose an email address. Finally, start the\nintent with `startIntentSenderForResult()`. \n\n HintRequest hintRequest = new HintRequest.Builder()\n .setHintPickerConfig(new CredentialPickerConfig.Builder()\n .setShowCancelButton(true)\n .build())\n .setEmailAddressIdentifierSupported(true)\n .setAccountTypes(IdentityProviders.GOOGLE)\n .build();\n\n PendingIntent intent = mCredentialsClient.getHintPickerIntent(hintRequest);\n try {\n startIntentSenderForResult(intent.getIntentSender(), RC_HINT, null, 0, 0, 0);\n } catch (IntentSender.SendIntentException e) {\n Log.e(TAG, \"Could not start hint picker Intent\", e);\n }\n\nThe user is prompted to choose an email address to use.\n\nThen, in the activity's `onActivityResult()` method, retrieve the hints from the\n`Credential.EXTRA_KEY` parcel, check whether the user is in your user database,\nand start the appropriate activity with the credentials hint. \n\n```transact-sql\n@Override\npublic void onActivityResult(int requestCode, int resultCode, Intent data) {\n super.onActivityResult(requestCode, resultCode, data);\n\n if (requestCode == RC_HINT) {\n if (resultCode == RESULT_OK) {\n Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);\n Intent intent;\n // Check for the user ID in your user database.\n if (userDatabaseContains(credential.getId())) {\n intent = new Intent(this, SignInActivity.class);\n } else {\n intent = new Intent(this, SignUpNewUserActivity.class);\n }\n intent.putExtra(\"com.mycompany.myapp.SIGNIN_HINTS\", credential);\n startActivity(intent);\n } else {\n Log.e(TAG, \"Hint Read: NOT OK\");\n Toast.makeText(this, \"Hint Read Failed\", Toast.LENGTH_SHORT).show();\n }\n }\n\n ...\n\n}\n```\n\nPre-fill the sign-in form\n-------------------------\n\nIf the user is in your user database and you started your app's sign-in\nactivity, you can (optionally) check if the `Credential` object contains an ID\ntoken. If so, you can [sign in the user with the ID token](/identity/smartlock-passwords/android/idtoken-auth),\nwithout requiring the user to type a password.\n\nIf the `Credential` object doesn't contain an ID token (or you don't want to use\nthe ID token), pre-fill the sign-in fields with the hints that you added to the\nintent. \n\n public class SignInActivity extends Activity {\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n Intent intent = getIntent();\n Credential credential = intent.getParcelableExtra(\"com.mycompany.myapp.SIGNIN_HINTS\");\n\n // Pre-fill ID field\n mUsernameView.setText(credential.getId());\n\n ...\n }\n\n ...\n }\n\nPre-fill the sign-up form\n-------------------------\n\nIf the user isn't in your user database and you started your app's sign-up\nactivity, pre-fill the sign-up fields with the sign-in hints that you added to\nthe intent. \n\n public class SignUpNewUserActivity extends Activity {\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n Intent intent = getIntent();\n Credential credential = intent.getParcelableExtra(\"com.mycompany.myapp.SIGNIN_HINTS\");\n\n // Pre-fill sign-up fields\n mUsernameView.setText(credential.getId());\n mDisplaynameView.setText(credential.getName()); // Might be null.\n\n ...\n }\n\n ...\n }\n\nOptionally, you can also check if the `Credential` object contains an\n[ID token](/identity/smartlock-passwords/android/idtoken-auth) that has a\nverified email address. If so, you can skip your app's email verification step,\nsince the email address has already been verified by Google."]]