> [!WARNING]
> **Deprecated:** Smart Lock for Passwords is deprecated. To ensure the continued security and usability of your app, [migrate to
> 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.

Requests to retrieve user credentials can fail when a user has not yet saved
credentials or when a user has not yet signed up to your app. In these
situations, use the Credentials API to retrieve sign-in hints, such as the
user's name and email address. Use these hints to pre-fill your app's sign-in
and sign-up forms, speeding up your app's on-boarding process.

On Android 6.0 (Marshmallow) and newer, your app does not need to request
any device or runtime permissions to retrieve sign-in hints with the
Credentials API.

## Before you begin

[Configure an Android Studio project](https://developers.google.com/identity/smartlock-passwords/android/get-started).

## Retrieve sign-in hints

To retrieve the sign-in hints, first configure the hint selector dialog by
creating a [`HintRequest`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/credentials/HintRequest.Builder)
object. Then, pass the `HintRequest` object to
[`CredentialsClient.getHintPickerIntent()`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/credentials/CredentialsClient#getHintPickerIntent(com.google.android.gms.auth.api.credentials.HintRequest))
to get an intent to prompt the user to choose an email address. Finally, start the
intent with `startIntentSenderForResult()`.

    HintRequest hintRequest = new HintRequest.Builder()
            .setHintPickerConfig(new CredentialPickerConfig.Builder()
                    .setShowCancelButton(true)
                    .build())
            .setEmailAddressIdentifierSupported(true)
            .setAccountTypes(IdentityProviders.GOOGLE)
            .build();

    PendingIntent intent = mCredentialsClient.getHintPickerIntent(hintRequest);
    try {
        startIntentSenderForResult(intent.getIntentSender(), RC_HINT, null, 0, 0, 0);
    } catch (IntentSender.SendIntentException e) {
        Log.e(TAG, "Could not start hint picker Intent", e);
    }

![Smart Lock sign-in hint chooser](https://developers.google.com/static/identity/smartlock-passwords/android/images/hint-chooser.png)

The user is prompted to choose an email address to use.

Then, in the activity's `onActivityResult()` method, retrieve the hints from the
`Credential.EXTRA_KEY` parcel, check whether the user is in your user database,
and start the appropriate activity with the credentials hint.

```
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_HINT) {
        if (resultCode == RESULT_OK) {
            Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
            Intent intent;
            // Check for the user ID in your user database.
            if (userDatabaseContains(credential.getId())) {
                intent = new Intent(this, SignInActivity.class);
            } else {
                intent = new Intent(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();
        }
    }

    ...

}
```

## Pre-fill the sign-in form

If the user is in your user database and you started your app's sign-in
activity, you can (optionally) check if the `Credential` object contains an ID
token. If so, you can [sign in the user with the ID token](https://developers.google.com/identity/smartlock-passwords/android/idtoken-auth),
without requiring the user to type a password.

If the `Credential` object doesn't contain an ID token (or you don't want to use
the ID token), pre-fill the sign-in fields with the hints that you added to the
intent.

    public class SignInActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            Intent intent = getIntent();
            Credential credential = intent.getParcelableExtra("com.mycompany.myapp.SIGNIN_HINTS");

            // Pre-fill ID field
            mUsernameView.setText(credential.getId());

            ...
        }

        ...
    }

## Pre-fill the sign-up form

If the user isn't in your user database and you started your app's sign-up
activity, pre-fill the sign-up fields with the sign-in hints that you added to
the intent.

    public class SignUpNewUserActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            Intent intent = getIntent();
            Credential credential = intent.getParcelableExtra("com.mycompany.myapp.SIGNIN_HINTS");

            // Pre-fill sign-up fields
            mUsernameView.setText(credential.getId());
            mDisplaynameView.setText(credential.getName()); // Might be null.

            ...
        }

        ...
    }

Optionally, you can also check if the `Credential` object contains an
[ID token](https://developers.google.com/identity/smartlock-passwords/android/idtoken-auth) that has a
verified email address. If so, you can skip your app's email verification step,
since the email address has already been verified by Google.