0% found this document useful (0 votes)
34 views7 pages

Practical No 28

The document outlines a practical exercise for creating a login application in Android, focusing on user input validation for username and password. It emphasizes the importance of clean user interfaces and proper validation techniques to enhance user experience. The practical aims to develop competencies in Android application development, including configuring the environment and using various UI components.

Uploaded by

Huzeefa Pathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views7 pages

Practical No 28

The document outlines a practical exercise for creating a login application in Android, focusing on user input validation for username and password. It emphasizes the importance of clean user interfaces and proper validation techniques to enhance user experience. The practical aims to develop competencies in Android application development, including configuring the environment and using various UI components.

Uploaded by

Huzeefa Pathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Mobile Application Development (22617) Practical No.

28

Practical No. 28: Create login application where you will have to validate username
and password till the username and password is not validated, login button should
remain disabled

I. Practical Significance
This day Login and Registration form in Android are part of every application out there. So,
when we are programming, we work with many registration forms. Forms can be very
different from a simple login or registration to a complex ordering form for any application.

II. Relevant Program Outcomes (POs)


PO1- Basic knowledge
PO2- Discipline knowledge
PO3- Experiments and practice
PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop various registration forms.
2. Able to develop the application with various kinds of validations.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Create sample application with login module. (Check username and password) On successful
login, Change Text View “Login Successful”. And on login fail, alert user using Toast “Login
fail”.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


With registration, how you can check data that the user has entered with simple validation.
Validation can check many conditions. We can verify if an email address is a valid email and if
a user entered all the required data, for instance, we check if Edit Text is empty for the first
and last name. We can prepare a way to notify the user that the data is not valid. On login
activity, we should check for password length. There are a few things login and registration
form need:
• Clean user interface.
• Validation (check if the email is an email and if the user entered all the data).
• Notifications for the user that the data is incorrect.

Maharashtra State Board of Technical Education 1


Mobile Application Development (22617) Practical No. 28

• Instructions for the user (e.g. how many characters are required for password).

VIII. Resources required (Additional)

Sr. Instrument /Object Specification Quantity Remarks


No.
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1
version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design more
such questions to ensure the achievement of identified CO.
1. Explain validation of user input?
2. List and explain various GUI components used to design the login form with validation.
3. Differentiate between Text View and Edit Text View.

(Space for answers)


Answers:
1. Input validation, also known as data validation, is the proper testing of any input supplied
by a user or application. Input validation prevents improperly formed data from entering an
information system. Because it is difficult to detect a malicious user who is trying to attack
software, applications should check and validate all input entered into a system.

2. TextView
EditText
Button
TextView: Android TextView is the basic building block for user interface components. Android
TextView is a user interface element that displays text to the user e.g. “Enter User name” etc.
EditText: In android, EditText is a user interface control which is used to allow the user to enter
or modify the text.
Button: In Android, Button represents a push button. A Push buttons can be clicked, or pressed
by the user to perform an action. Generally it has a label, or an image or both.

X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to create the login form with necessary validations like length of username
and password, empty text fields, count of unsuccessful login attempts.
Display the login successful/Unsuccessful toast message.

Maharashtra State Board of Technical Education 2


Mobile Application Development (22617) Practical No. 28

(Space for answers)

1.
//MainActivity.java
package com.jamiapolytechnic.experiment281;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MainActivity extends AppCompatActivity{


EditText fullname, username, email, password, confirm;
Button signup;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fullname = findViewById(R.id.fullname);
username = findViewById(R.id.username);
email = findViewById(R.id.email);
password = findViewById(R.id.password);
confirm = findViewById(R.id.confirm);
signup = findViewById(R.id.signup);

signup.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)

Maharashtra State Board of Technical Education 3


Mobile Application Development (22617) Practical No. 28

{
if (fullname.getText().length() == 0 ||
username.getText().length() == 0 ||
email.getText().length() == 0 ||
password.getText().length() == 0 ||
confirm.getText().length() == 0) {
Toast.makeText(getApplicationContext(), "All fields are compulsory",
Toast.LENGTH_LONG).show();
}
else if (!password.getText().toString().equals(confirm.getText().toString()))
{
Toast.makeText(getApplicationContext(), "Password doesn't match with Confirm
Password", Toast.LENGTH_LONG).show();
confirm.setText("");
}
else
{
String regex = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#&()–
[{}]:;',?/*~$^+=<>]).{8,20}$";
boolean validPassword = isValidPassword(password.getText().toString(), regex);
if (!validPassword)
{
Toast.makeText(getApplicationContext(), "Password length must be between 8
to 20 characters\n"
+ "Password must contain at least one small letter\n"
+ "Password must contain at least one capital letter\n"
+ "Password must contain at least one digit\n"
+ "Password must contain at least one special character/symbol.\n",
Toast.LENGTH_LONG).show();
}
}
}
boolean isValidPassword(String pass, String regex)
{
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(pass);

Maharashtra State Board of Technical Education 4


Mobile Application Development (22617) Practical No. 28

return matcher.matches();
}
});
}
}

//=====================================================================

//Add email.png, login.png, pass.png, user.png icons in drawable folder

//activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:layout_marginTop="50dp">

<EditText
android:id="@+id/fullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:drawableLeft="@drawable/user"
android:layout_marginBottom="20dp"
android:drawablePadding="10dp" />
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="User Name"

Maharashtra State Board of Technical Education 5


Mobile Application Development (22617) Practical No. 28

android:drawableLeft="@drawable/user"
android:layout_marginBottom="20dp"
android:drawablePadding="10dp" />
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:drawableLeft="@drawable/email"
android:layout_marginBottom="20dp"
android:drawablePadding="10dp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:drawableLeft="@drawable/pass"
android:layout_marginBottom="20dp"
android:drawablePadding="10dp" />
<EditText
android:id="@+id/confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Confirm Password"
android:inputType="textPassword"
android:drawableLeft="@drawable/pass"
android:layout_marginBottom="20dp"
android:drawablePadding="10dp" />
<Button
android:id="@+id/signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign Up"

Maharashtra State Board of Technical Education 6


Mobile Application Development (22617) Practical No. 28

android:gravity="center" />

</LinearLayout>

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage

Process related (10 Marks) 30%

1. Logic Formation 10%


2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%

4. Interactive GUI 20%


5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members


1
2
3
4

Marks Obtained Dated signature of


Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 7

You might also like