【问题标题】:How to get the user to auto fill framework setting screen pro-grammatically in android 8.0如何让用户在 android 8.0 中以编程方式自动填充框架设置屏幕
【发布时间】:2018-04-26 01:40:45
【问题描述】:

我想让用户自动填充框架设置屏幕以启用 AutoFill 框架在第三方应用程序中自动填充登录表单。

那么,如何以编程方式让用户进入 Oreo 设备中的自动填充设置屏幕?

【问题讨论】:

    标签: android android-8.0-oreo android-settings android-autofill-manager


    【解决方案1】:

    先决条件:

    用户必须启用自动填充服务。 设置 > 系统 > 语言和输入 > 高级 > 输入帮助 > 自动填充服务。

    1.提供自动填充提示

    自动填充服务通过提供可自动填充的每个视图的含义来正确分类数据,例如表示用户名和密码的视图。

    xml:

    android:autofillHints="AUTOFILL_HINT_USERNAME"
    

    Java:

    editText.setAutofillHints(View.AUTOFILL_HINT_USERNAME);
    

    2。强制自动填充请求

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

    【讨论】:

    • 我的问题是,我们可以让用户以编程方式自动填充设置屏幕,如下所示,以获取可访问性 startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
    • 是否可以检查它是否针对特定类型启用,例如电话号码?
    【解决方案2】:

    经过长时间的搜索,我从 gitup 项目中找到了答案。

    下面是让用户以编程方式自动填充设置屏幕的代码

       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);
        }
    

    【讨论】:

    • 谢谢,这就是我要找的!还有一个问题,你知道如何以编程方式禁用系统自动填充服务吗?
    猜你喜欢
    • 2022-11-10
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多