I am trying to make a form in android in which one of the fields is an email and I wanted to know if there is any way to automatically check if the email entered is correct and instead show something similar to what the following image shows:
I have specified the email field as follows:
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/letraAzul"
android:inputType="textEmailAddress"
android:textSize="@dimen/texto_letra"
android:hint="Email"/>
where android:inputType="textEmailAddress"
it is only in charge of showing a keyboard for the introduction of the email as the documentation says .
If there is no automatic way to check, what would be the best way to check that the email is correct?
Use:
android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()
- A regular expression of the type
"^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"
(which expression accepts more types of emails?) - Another way
Does anyone know how to do it or have any examples or documentation that can help me?
Cheers