【问题标题】:Is there any way to check email domain validity on android?有没有办法在安卓上检查电子邮件域的有效性?
【发布时间】:2026-02-24 18:15:02
【问题描述】:

我想知道,是否有办法在 android 上检查电子邮件域的有效性。而且我不是在问这种检查 -

android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();

我想知道域名是否有效,因为有时用户可能会出错,而不是xxx@gmail.com,他会写xxx@gmal.com等。谢谢

【问题讨论】:

标签: android validation email dns


【解决方案1】:

我认为下面的android库可以解决你的问题,

请参阅来自 github 的 AutoCompleteEmail 库。

1. Add it in your root build.gradle at the end of repositories:

dependencies {
        compile 'vn.tiki.widgets:autocompleteemail:1.0.1'
}

2. Usage In your folder values create arrays.xml

<resources>
  <string-array name="domains">
    <item>gmail.com</item>
    <item>yahoo.com</item>
    <item>tiki.vn</item>
    <item>hotmail.com</item>
    <item>co.jp</item>
  </string-array>
</resources>

3. In your layout XML

 <vn.tiki.widgets.AutoCompleteEmailEditText
              android:id="@+id/etEmail"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:inputType="textEmailAddress"
              app:domains="@array/domains"/>

快乐编码:)

【讨论】:

  • 谢谢,但这不是我正在寻找的解决方案。 5 个定义的域是不够的。世界上有很多域,你不能只是在数组中使用它们。
  • @Segi,好的,但它可以帮助您用作 Top 或 ** 最常用的 ** 世界范围内使用的域。
最近更新 更多