【发布时间】:2021-04-08 17:07:55
【问题描述】:
我在一些应用程序(不记得名字)中看到,在文本框下,会显示一个小弹出窗口,说
消息中的自动填充代码
我想为我的应用添加类似的功能。正如documentation 中所建议的那样,添加自动填充提示并设置自动填充重要性以实现此行为。我都试过了,但都没有奏效。 我已经尝试了以下
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_login"
android:layout_marginTop="@dimen/x60"
android:id="@+id/pin"
app:errorEnabled="true"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_centerHorizontal="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="PIN"
android:drawablePadding="@dimen/x16"
android:inputType="number"
android:maxLength="6"
android:id="@+id/et_pin"
android:importantForAutofill="yes"
android:autofillHints=".AUTOFILL_HINT_SMS_OTP"
android:drawableStart="@drawable/ic_pin"/>
</com.google.android.material.textfield.TextInputLayout>
我想在我的应用中获得这种类型的东西
【问题讨论】:
-
如果您收到了 OTP,那么您为什么建议用户添加 OTP。我的意思不是要求用户设置 otp,而是自动设置 otp。
-
应用程序无法从用户消息中获取 otp auto,我需要一些机制。我没有使用火力基地。 SMS 是使用 twillio 从我的服务器发送的。 Android 不允许读取用户短信来验证 otp。
-
Twillio 是否提供了一些关于成功或接收监听器(回调?
标签: android message autofill one-time-password