With the below code we can validate email address in android.
import android.os.Bundle
import android.view.View
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
private lateinit var editText: EditText
private lateinit var email: String
private val emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
title = "KotlinApp"
editText = findViewById(R.id.editText)
email = editText.text.toString().trim()
}
fun validateEmail(view: View?) {
if (email.matches(emailPattern.toRegex())) {
Toast.makeText(applicationContext, "Valid email address",
Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(applicationContext, "Invalid email address",
Toast.LENGTH_SHORT).show()
}
}
}
Invoke-customs are only supported starting with android 0 --min-api 26
What are the notifications available in android?
How to avoid multiple button click at same time in android?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
What is Intent? What is the difference between an implicit intent and an explicit intent?
How do I generate random numbers in Dart?
Android Studio project R can't find
Hide/Disable soft keyboard on Activity launch: Android
How to get complete address from latitude and longitude?
Decompile APK Files: How to Get Source Code - RRutors Guide
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Extract Date and Time from Long Type Variable - RRutors
How to Exit android app on back pressed?
How to find Android Device UDID or unique ID?
FCM Not Receiving Notifications in Android - RRutors
Key Points to remember while develop the Android Application.
What are Android Versions available?
Check List for Generate Signed APK Android
How to get a contact image using a phone number in android?
How to install/ uninstall apk by command line ADB
How To Set Text Color Programmatically Android TextView?
How do I check in SQLite whether a table exists?
What is "shared preferences" in Android ?
How to Get bitmap from drawable: Android
How to copy database from assets folder in android using kotlin
How to convert milli seconds to hours, minutes and seconds in Android?
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to reduce APK package size?
Fix Duplicate Files in APK Build.gradle Issue - RRutors
Fix Play Store Rejection Due to SMS Permission - RRutors
How to get screen size (width,height) in Android?
How to stop EditText focus at Activity startup in Android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What is the Different Between val and var in Kotlin?
How to start a new activity on button click
How to Use Deprecated Handler() in Android - RRutors Guide
How to Generate signed apk with android studio
How to check Android version?
Explain Fragment Life Cycle