I've built a little browser using the android webview component and am looking to integrate password/credential manager support using the Android AutoFill API.
I've read the docs but am completely lost and can't find any examples of integration with complex things like webviews.
The javascript side of this is not a problem for me, I already have events that are triggered when a user selects an input on a login form (and the auto-fill dialog should be presented), and when a finishes entering a username and password and submits the page (and the credentials should be saved back to the password manager) but I'm struggling to understand the android side of this.
The webview seems to have some basic support for this already, for example if I long press on a login form input, and select "auto-fill" in the context menu, I can get it to insert some values saved in the credential manager. The problem is though that the credentials have been saved against my app ID, not the website domain, so my first question, how do I tell the API that when I'm requesting the auto fill menu that it's for a specific field type (e.g. username/password) and belonging to a particular website so it knows which credentials to fetch and can update them later? Here is my attempt to trigger the auto-fill dialog to appear when selecting a field in the login form.
UPDATE:
When I create a static webview in my app the autofill correctly saves and prompts for credentials on forms and saves them correctly per site BUT I need this to work in webviews that are in a recyclerview and for some reason they don't despite sharing the same settings. I found this info about autofill in recyclerviews https://developer.android.com/guide/topics/text/autofill-optimize#recycle but using setAutofillId()
doesn't seem to help and even the official example here seems a bit unreliable when I test it on my phone https://github.com/android/input-samples/blob/master/AutofillFramework/Application/src/main/java/com/example/android/autofill/app/commoncases/RecyclerViewActivity.java