How to integrate autofill in Jetpack Compose
Asked Answered
N

2

11

I want to provide some autofill functionality in my app (email and password) that is written completely using Jetpack compose. I came across this blog post and this demo code which I both tried out. Unfortunately, I can't get any popup when interacting with the text fields.

After modifying my code, I ended up using the provided demo. A minimal example looks like this (the ExplicitAutofillTypesDemo composable is taken from the demo code mentioned above without any modification):

class MainActivity: AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            ExplicitAutofillTypesDemo()
        }
    }
}

What am I missing? Do I need to enable it somewhere else? The official compose autofill documentation is not very helpful. I only want to get a autofill popup when touching a text field like in the blog post above.

Norvall answered 13/7, 2021 at 10:2 Comment(0)
N
9

In my case, the popup was not showing due to the fact that autofill doesn't seem to work with any other provider than Google. The debug log shows the following message:

D/Autofill Status: Autofill popup isn't shown because autofill is not available.
    
    Did you set up autofill?
    1. Go to Settings > System > Languages&input > Advanced > Autofill Service
    2. Pick a service
    
    Did you add an account?
    1. Go to Settings > System > Languages&input > Advanced
    2. Click on the settings icon next to the Autofill Service
    3. Add your account

I tried the Microsoft Authenticator as an example which does not work. When I switch to Google, everything works as intended.

Norvall answered 13/7, 2021 at 10:19 Comment(1)
I couldn't understand what does it mean here by using provider as Google ? I have a simple app in which I would like to add this option. In debug mode I tried running this but in log this got printed. Other apps that I have on my device, this feature works fine. What am I missing. I already have autofill-service account addedErlanger
C
0

There is an open Jetpack Compose issue on the case of supporting other authentication providers for autofill, so even in 2024 this is not working for other services than Google Password Manager.

Chalutz answered 11/7 at 6:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.