How can I verify a user enters email address in a EditTextPreference
for android setting ?
By the way, You can use inputType
in EditText
to validate the input as email by the system!
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText" />
You can use the default utility to validate!
boolean isEmailValid(CharSequence email) {
return android.util.Patterns.EMAIL_ADDRESS.matcher(email)
.matches();