androidandroid-jetpack-composeautofillandroid-autofill-managerpassword-manager

How to trigger Google Password Manager in native XML view to show popup to save user's password to use later in AutofillService?


I have a usual screen with "email" and "password" EditText fields. I have marked my fields with autofillHints, so that Android AutofillService could propose user already saved passwords. It's working. But looks like it only propose only that passwords which where previously entered in browser or somewhere else and where saved to my Google's accound via Google Password Manager. But those successful pairs of email and password, which where entered via native app Fragment -- it is not saving them after the login procedure. But I want to save those users credentials after successful Login/Register flow to be able them to be used via AutofillService to propose user to login with them. So I assume there should be some sort of API which I can trigger in onLoginSuccess() method and save those credentials in Google Password Manager or whenever available Google Service to make it available to Autofill Service next time.

Offer to save passwords - enabled, AutofillService also enabled:

https://www.lifewire.com/how-to-manage-android-autofill-settings-4801221

AutofillService: https://developer.android.com/guide/topics/text/autofill-optimize

AutofillService for Jetpack compose: https://developer.android.com/reference/kotlin/androidx/compose/ui/autofill/package-summary

So How to trigger Google Password Manager in native XML view or Jetpack Compose to show popup to save user's password to use later in AutofillService? Thanks.


Solution

  • I have solved my issue with such libraries from Google:

    1. Smart Lock for Passwords: https://developers.google.com/identity/smartlock-passwords/android/overview (outdated)

    2. One Tap sign-in on Android: https://developers.google.com/identity/one-tap/android/overview (new one)

    I personaly have used Smart Lock for Passwords (it's already outdated), but for my solution it works great and needs only little customization. Because One Tap needs more time to proper set it up on server side to work with security tokens. But pay attention - both of these libraries don't work in conjunction with Autofill Service with Jatpack compose. Probably they work with Autofill Service which is used with XML layouts, but is what I have discovered.