Android Tutorial

Android Tutorial Android Toast Button Widget In Android Tutorial Imageview Widget In Android Android Date Picker Example Android Time Picker Example Android Operating System Android Activity Android Architecture Android Content Providers Android Edittext Android Emulator Android Fragments Android Gridview Android Broadcast Receivers Event Handling In Android What Is Android Studio Android Navigation Drawer Android Recyclerview Android Scrollview Android Navigation Android Operating System Android ListView Android Studio Resources Android Studio's Layout Editor Android TextView Android Styles and Themes How To Show Image On An Android Application How To Insert An Email In Android Application In Android Version 8 How To Insert The Mobile Number On An Android Application Using Edittext Difference between android developer and web AdapterViewFlipper in Android with Example Android 9.0 Pie vs. Android 10, which one is better Android Development or Web Development which one is the best to choose Android Project Folder Structure Assets folder in Android How to reduce the size of APK in Android Top 7 Android App Development Books Top Programming Languages for Android Development Android Navigation Application Components Difference between android developer and web developer Event Handling in Android How to reduce the size of APK in Android Top 7 Android App Development Books Top Programming Languages for Android Development AdapterViewFlipper in Android with Example Android 9.0 “Pie” vs. Android 10, which one is better Android Development or Web Development which one is the best to choose Android EditText Android Fragments How to Update Gradle in Android Studio Navigation Drawer ScrollView What is Android Studio? Android Architecture Android Content Providers Android GridView Android RecyclerView Android Studio’s Layout Editor

How to insert an email in android application in android version 8

Email Address Insertion

It is used to insert email adrress from the user in the android application.The only point of difference between an EditText and an Emailtext is that EmailText consisits of attribute named as android:inputType="textEmailAddress".

Email address consists of a local part followed by '@' and then a case sensitive domain name.

In this tutorial, we are going to demonstrate the use of Email Edit text.

Step 1: Create a brand new android project on android studio IDE.

/></figure>
<!-- /wp:image -->


<!-- wp:list -->
<ul><li>Open the android studio</li><li>Select create a new project</li><li>Insert your application name, company domain(if any) and the location of the project press on next and then finish.</li></ul>
<!-- /wp:list -->


<!-- wp:paragraph -->
<p><strong>Step 2:</strong> After creating the new android studio project, you will be displayed XML file and a java file corresponding to it.</p>
<!-- /wp:paragraph -->


<!-- wp:paragraph -->
<p><strong>Step 3:</strong></p>
<!-- /wp:paragraph -->


<!-- wp:image {

In the next step, select the activity_main.xml file to access the front-end side of the android application.

Step 4: Go to the design tab and select email under text.

Step 5: Drag and drop email on your android application preview.

After getting the email edit text XML file will look like this:-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
    android:id="@+id/layout">


    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="173dp"
        android:ems="10"
        android:inputType="textEmailAddress" />
</RelativeLayout>

android:inputType="textEmailAddress"

This line represents an Edit text as an textEmailAdress i.e. this Edit Text will be used to insert email from the user.

After the step 5, front-end work is completed, you can take a button for 'submit' according to your requirement. You can also go through my android Button tutorial to understand the working of button in android application.

Step 6: Insert the following code in your Main Activity file:

import android.widget.EditText;

Step 7: Insert the following code in your MainActivity class:

private EditText email;

This will create an instance variable of class EditText as email.

Step 8: Inside the onCreate method of your MainActivity class, insert the following code:

email=findViewById(R.id.editText);
String mail=email.getText().toString();

This will initialize the email instance.

Step 9: In the final step, you can use the String mail to get the email inserted by the user.

Developer may check the email-address entered by the user against the email in his database via mail String.

I would suggest you to take a button to insert the email from the user.

Insert the following code on your onCreate method inside the

MainActivity.java file:

if([email protected]){
Toast.makeText(MainActivity.this,"Welcome [email protected]",Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(MainActivity.this,"Not a valid user",Toast.LENGTH_SHORT).show();
}