[英]Autofill Framework disabled in app, but enabled in other apps
嘗試對登錄片段使用自動填充框架時遇到問題,它沒有顯示保存彈出窗口。 我在兩個文本字段上都放置了android:autofillHints
屬性,然后在兩個結果上都嘗試了android:importantForAutofill="yes"
,並且還嘗試手動調用AutofillManager.requestAutofill()
和AutofillManager.commit()
。
接下來,我從這里下載了一個示例並進行安裝,它可以正常工作。 我使用調試來檢查兩個應用程序中的AutofillManager.isEnabled()
結果發現AutofillManager.isEnabled()
會產生不同的結果:在示例應用程序中為true,在我的應用程序中為false。 在這兩種情況下,我都在應用程序的第一個活動中檢查了onCreate()
的第一行,在兩種情況下均不包含要填充的字段。
這就是為什么我認為問題不在代碼或布局文件中,而是在gradle或清單文件中,但是我找不到可能影響自動填充框架的任何區別。 我認為框架也沒有配置值。 我檢查了targetSdk和minSdk,但是不是
我還應該檢查什么?
AutofillManager.isEnabled()
不應在您的應用程序或示例應用程序上產生不同的結果,我的猜測是您使用錯誤的上下文來獲取管理器,應該是Activity
。
您可能需要配置自動填充服務,並且需要在onProvideAutofillStructure方法中添加視圖數據綁定邏輯。
<!--
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.