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()
}
}
}
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
Key Points to remember while develop the Android Application.
What are symmetric and asymmetric encryption in the way Android interacts with the server?
How do I generate random numbers in Dart?
How to add jar/library files as a dependency in Android studio gradle file
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
How to get a contact image using a phone number in android?
How to find Android Device UDID or unique ID?
How to save activity State in Android?
What is Application?
Could not inflate Behavior subclass android.support.design.widget. BottomSheetBehavior How resolve
What is Context?
How to Exit android app on back pressed?
How to get an image resource by it's name in android?
What is NetworkOnMainThread Exception?
How to reduce APK package size?
Explain Fragment Life Cycle
How to Get bitmap from drawable: Android
How To Set Text Color Programmatically Android TextView?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
How to start a new activity on button click
What is ANR in android?
Check List for Generate Signed APK Android
ERR_ACCESS_DENIED in Android Webview with sdk 30
Android FCM not receiving notifications when app is removed from background
Hide/Disable soft keyboard on Activity launch: Android
What is the difference between match_parent and fill_parent?
What happens next when the device switches between portrait and landscape?
How to copy database from assets folder in android using kotlin
How to extract date and time from Long type variable in Kotlin on Android "
How to install/ uninstall apk by command line ADB
Duplicate files during packaging of APK” build.gradle issue: Android Studio
Android Studio project R can't find
What are the notifications available in android?
How can i comment inside xml file in android studio?
How to get complete address from latitude and longitude?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What are Android Versions available?
What is the Different Between val and var in Kotlin?
How to stop EditText focus at Activity startup in Android?