android - 如何在没有 AccountManager 或权限的情况下在 EditText 上显示用户电子邮件

标签 android

我见过很多应用程序,当我单击电子邮件的 EditText 时,它会显示我在设备上使用的电子邮件列表,例如图像 auto fill email

我确信它不是 AccountManager,因为它没有请求我的许可,也不是 Google 智能锁 另外,我尝试了自动填充服务

<android.support.design.widget.TextInputLayout
        android:id="@+id/editNameInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/editName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/name"
            android:imeOptions="actionNext"
            android:inputType="text"
            android:textAlignment="viewStart"/>

    </android.support.design.widget.TextInputLayout>

并以编程方式但它不起作用

 editEmail.setAutofillHints(View.AUTOFILL_HINT_EMAIL_ADDRESS);
 editEmail.setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_YES);

最佳答案

Autofill framework提供填写先前输入的密码、信用卡号等功能。

您可以设置autofillhints以允许此框架填写详细信息。

关注Optimize your app for autofill了解更多详情

注意:

An autofill service must be configured on your device for your app to use the autofill framework. Although most phones and tablets running Android 8.0 (API level 26) and higher ship with an autofill service, we recommend that you use a test service when testing your app

关于android - 如何在没有 AccountManager 或权限的情况下在 EditText 上显示用户电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52167977/

相关文章:

android adt bundle 自动扩展 ActionBarActivity 并添加 fragment 和更多东西?

android - 如何在 Android Studio 2.3 插桩测试中添加额外的测试运行器参数

android - 如何在果酱模拟器上设置横向?

android - 如何使用 Lollipop MR1 多 SIM 卡支持(通过 SubscriptionManager)获取所有 SIM 卡的 IMEI?

Android - 使用 runOnUiThread 从线程进行 UI 更改

android - ElementList SimpleXML 中的空条目

android - 当显示和关闭自定义对话框时, Activity 中的 Kotlin 合成 View 变为空

javascript - react native map 执行任务 ':react-native-maps:checkDebugManifest'失败

java - 将在 native 代码中缓存 jclass 防止类被卸载

android - 膨胀类 fragment 时出错 - 重复 id/illegalargumentexception?