Reputation: 114
I ran into problems when trying to use Autofill Framework for the login fragment, it does not show the save popup. I placed android:autofillHints
attribute on both text fields, then I tried android:importantForAutofill="yes"
on both with the same results, and I also tried to call AutofillManager.requestAutofill()
and AutofillManager.commit()
manually.
Next I downloaded an example from here and installed it, and it worked normally. I used debug to check AutofillManager in both apps and it turned out that AutofillManager.isEnabled()
produces different results: true in a sample app and false in my app. In both cases I checked the first line of onCreate()
in a first activity of an app, which in both cases does not contain fields to be filled.
That's why I think a problem is not in the code or layout files, but rather in the gradle or manifest files, but I could not find any difference in those that could have affected the Autofill Framework. I do not think that framework also has configuration values. I checked targetSdk and minSdk, but that's not it
What else should I check?
Upvotes: 2
Views: 3073
Reputation: 11
Switching to Activity
context did the trick for me, didn't work with Application
or Service
context before.
Upvotes: 0
Reputation: 1217
You might need to Configure an autofill service and you need to add view data binding logic in the onProvideAutofillStructure method.
<!--
Declare AutofillService implementation; only needed for a small number of apps that will
be implementing an AutofillService. Framework parses meta-data and sets the service's
Settings Activity based on what the meta-data resource points to.
-->
<service
android:name=".MyAutofillService"
android:label="Multi-Dataset Autofill Service"
android:permission="android.permission.BIND_AUTOFILL_SERVICE">
<meta-data
android:name="android.autofill"
android:resource="@xml/multidataset_service" />
<intent-filter>
<action android:name="android.service.autofill.AutofillService" />
</intent-filter>
</service>
Upvotes: 0
Reputation: 181
AutofillManager.isEnabled()
should not produce different results on your app or the sample app, my guess is that you're using the wrong context to get the manager, it should be the Activity
.
Upvotes: 1