【发布时间】:2018-01-19 12:17:30
【问题描述】:
我已使用compileSdkVersion 26 将我的应用配置为支持 Android Oreo。我还为我的电话号码输入字段设置了android:autofillHints="phone"。当我点击该字段时,我可以看到 “自动填充” 弹出。但是,当我点击 "Autofill" 时,"Contents can't be autofill" toast 出现,我在 logcat 中看到以下跟踪:
RemoteFillService Not handling { when=-3ms what=3 target=com.android.internal.os.HandlerCaller$MyHandler } as service for ComponentInfo{com.google.android.gms/com.google.android.gms.autofill.service.AutofillService} is already destroyed
View dispatchProvideAutofillStructure(): not laid out, ignoring
我应该如何解决这个问题?我已确认我已在 设置 > 系统 > 语言和输入 > 高级 > 输入帮助 > 自动填充服务中配置了电话号码。
使用示例 XML 更新:在 API 26 模拟器设置中,我可以选择“使用 Google 自动填充”。使用Android Studio的Design选项卡,我添加了一个“Phone”类型EditText,然后在XML元素中手动插入android:autofillHints="phone":
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone"
android:autofillHints="phone" />
使用此 XML 可以观察到上述 Logcat 特性。
【问题讨论】:
-
除了新添加的
android:autofillHints="phone"之外,XML或代码没有什么特别之处。我会尽量找时间详细说明。但是,Google 的自动填充功能在其当前状态下似乎有点不成熟:plus.google.com/+JuusoOhtonen/posts/4kzMk5LUGLW -
第一:不,我没有悬赏 250。第二:正如我在 Google Plus 帖子中所展示的,我目前什至无法选择“使用 Google 自动填充”,所以我真的无法提供可验证的示例(因为我目前无法自己验证)。
-
我可以在 API 26 模拟器上使用“使用 Google 自动填充”。基于此,我更新了问题以包含 XML 元素。
-
现在工作 1.9.17
-
更新:今天更新我的 Google Pixel XL 设备后,
autofill完美运行(无需额外更改代码)!
标签: android android-logcat autofill android-8.0-oreo