Tuesday, December 14, 2010

Sample Android Login Application

After developing wide range of Java applications including Web and Desktop based since about four and half years now I have started learning Android Since last one month and day by day I'm getting very keen in learning the Same.

Following is the Sample Android Login Application which I have developed and would like to share with everyone.
This Application is at its very basic stage, Irrespective of the database used.

It works as follows:
If User Name and Password Entered are similar it gives a Toast pop up saying that "Login Successful"
Else It will give a Toast pop up Saying that "Invalid Login"

I feel it will help the Android learning beginners:

This application is developed on Following platforms:
Ubuntu 10.10,
Eclipse 3.5 Galileo
Android 2.1 SDK

Following is the Screen short of the Application:

Following is the Screen short of the Application:

I have used Table Layout, Following is the Layout Code for the Same:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:text="User Name: " 


android:text="Password: " 






Following is the Activity Code for the Application:

package com.mayuri.login;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SampleLogin extends Activity {

EditText txtUserName;
EditText txtPassword;
Button btnLogin;
Button btnCancel;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        btnLogin.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

        Toast.makeText(SampleLogin.this, "Login Successful",Toast.LENGTH_LONG).show();
       } else{
        Toast.makeText(SampleLogin.this, "Invalid Login",Toast.LENGTH_LONG).show();


Following are the Screenshots of the Applications, Depending on their behaviours i.e. "Login Success" and "Invalid Login".

I hope this example proves to be useful to the people learning Android.
I will keep on updating with more and more examples.


Best Car pool Android Application Best Car Pool Application Source Code Download Here

Best Social Network Cordova Ionic Application Best Social Networking Source Code Cordova Ioinc Application Download Here

Best Android Application, Android Restaurant System Best Android Restaurant Application Source code download here

Best Android Application Android Chat Source code download Android Chat Source code download

Best Android Quiz Source Code Download Best Android Quiz Source Code Download here

More and Lots of useful Android source codes here Best Android Source codes download here


akhtar said...

Good work ...thank you
can you please show how to start the sub_activity from the same activity by using intents????

Mayuri Ruparel said...

Thanks Akhtar!

Try this:

Intent myIntent = new Intent(view.getContext(), ActivityClassName.class);
startActivityForResult(myIntent, 0);

Nazim said...

Its a Mind blowing work for android developers. mayuri mam is my guru.
thanks a lot mam.

Satyam said...

Thanks I am finding this type of login form ..

With use of database how datafetch??

Satyam said...

thaks I am looking for this type of loginform

Hello ,can you please find how to fetch data form databse...

using of webservices...

Test Blog said...
This comment has been removed by the author.
Test Blog said...
This comment has been removed by the author.
Test Blog said...

I just want to knw that how to check whether the edittext is focused or not can u plz tell me which method i should use

i tried isFocused() and hasFocus() but dint work.....

Anonymous said...

Can you please let me know how I can modify this code to connect to a remote data base . I would appreciate if you send me the lines of code

KUPPA said...

Hi, Thanks for this tutorial....
But actually iam searching for login application i.e)username and password are stored in database or server.. when i enterd username&password values server or database will check these two values.. if it matches it will return success otherwise failure.... pls help me :P

Android app development said...

Android is an operating system such as mobile devices like smart phones and tablet computers.Android is a Linux base mobile application which is providing very fastest services .This Android Incredible features get good popularity In market.Android has a large community of developers writing applications that extend the functionality of the devices.We are also providing good logic to develop more In this field.
Android app developers

Android developer said...

I would like to thank for creating this interesting blog, because its having the good knowledge about android. so its useful to me.

Android developer

ferdaws said...

please how can i connect to my mysql database from this form ???

ans patel said...

pls tell me,
how to login my mail address from my android application???

Er. Vikas Gupta said...

superb... Thanks a lot, its really helpfull to everyone who have no idea of xml (like me ) in creating android basic app.. once again thank you so much.. :)

sudhursun said...

do you have any ideas of creating database and viewing database using timepicker...it will be very useful if you help i am a student doing finalyear project.........

sudhursun said...

Can you help me with creating database using timepicker............I am doing it for final year college project thanks in advance

satheesh said...


Hi this app is very useful to me. YQ

Unknown said...

gatchu mayuri

Unknown said...

gatchu mayuri

Unknown said...

i dun know what to do with this @override line , em getting some error in onclick (view v) line ,
i dun have any knowledge regarding android , just that i have appointed to do a project on android , so i have to learn it asap ... please guide me thats my first task making a simple login form and em not getting anything .. :(

Unknown said...

i dun know what to do with this @override line , em getting some error in onclick (view v) line ,
i dun have any knowledge regarding android , just that i have appointed to do a project on android , so i have to learn it asap ... please guide me thats my first task making a simple login form and em not getting anything .. :(

Baradwaj Aryasomayajula said...

I am unable to enter the values into EditText....
Can u help me....

Unknown said...

mam plz tell me how i can crete my sqldatabase

Irfan Shaikh said...

can u create web app for login using servlets & jsp & import it into ur android project ???

pavankumar said...

Hi Mayuri,

thanks for providng data for login form...i need some more information from that data like how to fetch the same code through database through different un and pwd's???can u please provide if you have that type of data...

Pavan Kumar

Unknown said...

Thanks for your post mayuri... This example was quite helpful. I have also referred this site http://androidtechstuffs.blogspot.in/2013/01/login-application-for-android.html, which looks quite useful. Have a look!!

Unknown said...

Thanks. This Code really helped me out. I want some modification in this code, I want to switch another Screen
I have used the Intent but it is showing me error.. Will u plz. help me.?

Unknown said...
This comment has been removed by the author.
Unknown said...

hi Mayuri
i want signup page program with database.can u help me

William Benjamin said...

Good One yaar , Thank'z for Your Code.

Anonymous said...

Could you please provide me a login and registration sourse code using sqlite and eclipse:
There should be a reset button on registration page. And after login directed to a new welcome page.

Please provide me this code as soon as possible.

Unknown said...

Can any body Explain how to authenticate login from remote server through PHP and MysQl.. I have tried several Tutorial nut unable to resolve the issue . My emulator gets stuck when ever i make any request to the server (Xaampp).

nabler rastaman said...

Awesome mayuri

@Nauman Shaw use phonegap man

Sanjay said...

I tried this app and most of it works.
I copied the code snippets from here to a fullscreen app.
My username field overlaps the app name field on the top left?
still trying to find the reason and rectify this
Thanks Mayuri,

Sanjay said...

I found one solution for this - by setting marginTop as a value

Unknown said...

Hi, may I know the connectivity coding for the same example shown above?
Thank you

Unknown said...

please tell me how to handle the error "unfortunately has stopped "

contact me by: tsegay.gm@gmail.com

Juan Tomaylla said...

Thanks Akhtar! I used to login in a sqlserver, impressive code!!

navya said...

Great and Useful Article.
Java Online Training

Online Java Course

Java Course Online

J2EE training

online J2EE training

Best Recommended books for Spring framework

Java Interview Questions

Java Training Institutes in Chennai

Java Training in Chennai

J2EE Training in Chennai

java j2ee training institutes in chennai

Java Course in Chennai

Unknown said...

Thanks for sharing this post

Dealersocket Login

sheela rajesh said...

Nice idea,keep sharing your ideas with us.i hope this information's will be helpful for the new learners.
Android Training in Chennai
Android Training in Velachery
JAVA Training in Chennai
Python Training in Chennai
Hadoop Training in Chennai
Digital Marketing Course in Chennai
Android Training in Chennai
Android Training in T Nagar

Tuhin said...

keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
digital marketing training in bangalore / https://www.excelr.com/digital-marketing-training-in-bangalore

riyaz said...

Thanks for taking time to share this post. It is really useful. Continue sharing more like this.
Android Training Institute in Chennai | Android Training Institute in anna nagar | Android Training Institute in omr | Android Training Institute in porur | Android Training Institute in tambaram | Android Training Institute in velachery

saran said...

Really nice post. Thank you for sharing amazing information.
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery

Animated Container in Flutter

Please check this flutter video tutorial for detailed example and implementation of Animated Container in Flutter.