简体   繁体   English

如何在Android 8.0中以编程方式让用户自动填充框架设置屏幕

[英]How to get the user to auto fill framework setting screen pro-grammatically in android 8.0

I want to get the user to auto-fill framework settings screen to enable the AutoFill framework to auto-fill the login form in third-party apps. 我想让用户自动填写框架设置屏幕,以使AutoFill框架能够自动填写第三方应用程序中的登录表单。

So, how can I get the user programmatically to the auto-fill settings screen in Oreo devices? 那么,如何通过编程方式使用户进入Oreo设备的自动填充设置屏幕?

Prerequistes: Prerequistes:

User must to Enable the Autofill service. 用户必须启用自动填充服务。 Settings > System > Languages & input > Advanced > Input assistance > Autofill service. 设置>系统>语言和输入法>高级>输入法帮助>自动填充服务。

1.Providing hints for autofill 1.提供自动填充提示

autofill service classify the data correctly by providing the meaning of each view that could be autofillable, such as views representing usernames and passwords. 自动填充服务通过提供每个可以自动填充的视图的含义(例如表示用户名和密码的视图)来正确地对数据进行分类。

xml : xml:

android:autofillHints="AUTOFILL_HINT_USERNAME"

or 要么

Java : Java的:

editText.setAutofillHints(View.AUTOFILL_HINT_USERNAME);

2. Force an autofill request 2.强制执行自动填充请求

AutofillManager afm = getSystemService(AutofillManager.class);
if (afm != null) {
    if (afm.isEnabled()) {   //for afmanager is enabled or not
        afm.requestAutofill(editText);
    }
}

After a long search i have found answer from gitup projects. 经过长时间的搜索,我从gitup项目中找到了答案。

The code to get the user to auto fill settings screen pro-grammatically is below 下面是使用户以编程方式自动填充设置屏幕的代码

   if (mAutofillManager != null && !mAutofillManager.hasEnabledAutofillServices()) {
        Intent intent = new Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE);
        intent.setData(Uri.parse("package:com.example.android"));
        startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM