top of page

Learn Android App Dev: Designing a simple Login App

Hey Guys! This is Amey Lokhande. In this post I will be guiding you on how to develop a simple Login App. These days every other app requires a login. So I thought that discussing about a Login App will be good idea.

Well, to design a Login App we require two credentials, viz. Username and Password. So we will put two fields for that and in addition to them I am going to put one Attempts counter which will disable the Login button once you exceed the number of wrong attempts of Username and Password. So lets begin!

Here are the steps:

1. First of all, we will design the first activity i.e the Login Page and after a successful login we will redirect the user to a new page.

2. Drag some TextViews and EditTexts to enter the username and for all other stuff. You can see what you need to drag in the screenshot below.

3. Then create a new activity. The new Activity will start after a successful login. Give a simple design to the next Activity. For ex, just drag a simple TextView and write "Welcome! You have successfully logged in."

Name the second activity as User_activity.

Note: If you dont know how to create a new Activity, please see my previous posts.

Click here to learn how to create a new Activity.

4. Now we lets design the Java code:

i) First of all, declare the EditTexts, TextViews and Button inside your MainActivity class.

ii) Also take a new Integer Variable "Attempts_counter" which will be used to count the number of wrong attempts.

iii) Then create a method to make the app work accordingly.

iv) Use a If statement to check the username and password. If it is correct, then show a Toast message about correct username and password. Also we have to start a new Activity.

v) Else the username or password is incorrect, then decrease the attempts counter and show a toast message about incorrect username and password. If the attempts counter goes to zero, then disable the Login button.

Here is the screenshot of the Working app:

Thats all!

Thanks!!

bottom of page