Download as pdf or txt
Download as pdf or txt
You are on page 1of 107

LABORATORY MANUAL REPORT

MOBILE APPLICATION DEVELOPMENT


LABORATORY

SIDDAGANGA INSTITUTE OF TECHNOLOGY


(An Autonomous Institute, Affiliated to Visvesvaraya Technological University Belagavi, Approved by
AICTE, New Delhi, Accredited by NAAC and ISO 9001:2015 certified)
B.H. road, Tumkur 572103, Karnataka, India.

Submitted in partial fulfillment of the requirements for the 4th Semester

BACHELOR OF ENGINEERING
IN

INFORMATION SCIENCE AND ENGINEERING

Submitted By:

1. Ravindra Savadatti 1SI22IS074


2. Srikanta Murthy N G 1SI22IS103
3. Suhas K N 1SI22IS105

Faculty Incharge:

Mrs. RAJANI G N
Associate Professor, Department of Information Science & Engineering
Siddaganga Institute of Technology, Tumakuru-572103.
Academic Year: -2023-24
ACKNOWLEDGEMENT

With reverential pranams, we express our sincere gratitude and salutations to His Holiness Dr.Sree
Sree Sivakumara Swamigalu and His Holiness Sree Sree Siddalinga Swamigalu of Sree Siddaganga
Mutt for their unlimited blessings.

First and foremost, we wish to express our deep sincere feelings of gratitude to our institution,
Siddaganga Institute of Technology, for providing us an opportunity for completing our project
successfully.

We are grateful to Dr. M N Channabasappa, Director, Siddaganga Institute of Technology,


Tumakuru for his kind cooperation and encouragement.

We express our kind thanks to Sr. Shivakumariah, CEO and Joint Secretary, SSES and Dr. S.V
Dinesh, Principal, Siddaganga Institute of Technology, Tumakuru for their encouragement towards
student attitude.

We express our heartfelt thanks to Dr. R. Aparna, Professor and Head, Department of
Information Science and Engineering, Siddaganga Institute of Technology, Tumakuru for her
suggestions and advice.

We express our heart full gratitude and humble thanks to our faculty in charge, Mrs. Rajani G N,
Assistant Professor, Department of Information Science and Engineering, Siddaganga Institute of
Technology, Tumakuru for guiding and facilitating to complete our Mobile Application laboratory
successfully.

We are conscious of the fact that we have received cooperation in many ways from the Teaching,
Technical and supporting staffs of the Department of Information Science and Engineering and we are
grateful to all for their cooperation.

We express heartfelt gratitude to our parents and friends for their constant moral support and
encouragement throughout this work.

-Ravindra Savadatti

-Srikanta Murthy N G

-Suhas K N
SIDDAGANGA INSTITUTE OF TECHNOLOGY
TUMAKURU-572103
Department of Information Science and Engineering

CERTIFICATE

This is to certify that the laboratory programs and the open ended experiment entitled “Farmer’s E-
commerce Application” has been successfully carried out by Ravindra Savadatti bearing USN
1SI22IS074, Srikanta Murthy N G bearing USN 1SI22IS103 and, Suhas K N bearing USN
1SI22IS105 at Siddaganga Institute of Technology Tumkur, in partial fulfillment of the
requirements for 4 t h Semester of Bachelor of Engineering in Information Science and
Engineering of affiliated to Visvesvaraya Technological University, Belgaum, during the academic
year 2023-2024. It is certified that all corrections/suggestions indicated have been incorporated in the
report deposited in departmental library. The lab work has been approved as it satisfies the academic
requirements in respect of lab work carried out in 4th semester prescribed for the Bachelor of
Engineering Degree.

Signature of Faculty Signature of HOD

_______________ _________________
Mrs. Rajani G N, Dr. R Aparna,
Assistant Professor, Professor and Head,
Dept. Of ISE, Dept. Of ISE,
SIT Tumakur. SIT Tumakur.
TABLE OF CONTENTS

Experiment Date Name of the Experiment Page Number


Number

1 12/04/2024 Create an application to display “Welcome 01-08


to Android Laboratory”.

2 24/04/2024 Create an application to design a Visiting 09-17


Card. The Visiting card should have a
company logo at the top right corner. The
company name should be displayed in
Capital letters, aligned to the centre.
Information like the name of the employee,
job title, phone number, address, email, fax
and the website address are to be
displayed. Insert a horizontal line between
the job title and the phone number.

3 24/04/2024 Develop an Android application using 18-26


controls like Button, TextView, EditText for
designing a calculator having basic
functionality like Addition, Subtraction,
Multiplication, and Division.

4 10/05/2024 a. Develop an android application to 27-47


demonstrate explicit intent.
b. Develop an android application to
demonstrate implicit intent.

5 24/05/2024 Create a SIGNUp activity with Username 48-67


and Password. Validation of password
should happen based on the following rules:
• Password should contain uppercase and
lowercase letters.
• Password should contain letters and
numbers.
• Password should contain special
characters.
• Minimum length of the password (the
default value is 8).
On successful SIGN UP proceed to the next
Login activity. Here the user should SIGN IN
using the Username and Password created
during signup activity. If the Username and
Password are matched, then navigate to the
next activity which displays a message
saying, “Successful Login” or else display a
toast message saying, “Login Failed”. The
user is given only two attempts and after
that display a toast message saying, “Failed
Login Attempts” and disable the SIGN IN
button. Use Bundle to transfer information
from one activity to another.

6 31/05/2024 Develop an application to set an image as 68-74


wallpaper. On click of a button, the
wallpaper image should start to change
randomly every 30 seconds.

7 07/06/2024 Write a program to create an activity with 75-81


two buttons START and STOP. On pressing
of the START button, the activity must start
the counter by displaying the numbers from
One and the counter must keep on counting
until the STOP button is pressed. Display the
counter value in a TextView control.

8 14/06/2024 Create an activity like a phone dialler with 82-94


CALL and SAVE buttons. On pressing the
CALL button, it must call the phone number
and on pressing the SAVE button it must
save the number to the phone contacts.

9 28/06/2024 Write an android program to demonstrate 95-98


scroll view and list view. (List view should
array adapter. The adapter should use array
list of companies. Each item in the list view
should have company name, company
address and its annual revenue.)

10 05/07/2024 Write an android program to display 99-102


different shapes.
MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-1: Create an application to display “Welcome to Android


Laboratory”.

XML Design:

1. Firstly, Create an Application by Name “VisitingCardApp”.


2. Go to xml code of design change the layout to “RelativeLayout”.
3. Add ImageView to design and in type choose “IC_LAUNCHER_FOREGROUND”.
• Download the logo & copy the same in res->drawable folder.
• In xml code of imageview change srcCompat=”@drawable/logo”.
• Align center.
4. Add TextView component change the following properties:
• Size: 24sp
• Text: SIDDAGANGA INSTITUTE OF TECHNOLOGY
• Align center.
5. Add TextView component change the following properties:
• Size: 16sp
• Text: An autonomous institute affiliated to AICTE
• Align center.
6. Add TextView component change the following properties:
• Size: 16sp
• Text: B.H. Road, Tumkur - 572103
• Align center.
7. Add Button component & change the following properties in XML.
• Id: “@+id/button”.
• Text: “click here to continue”

XML Code:

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

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

<androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schem
as.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/main"
android:layout_width="match_parent"

android:layout_height="match_parent"
tools:context=".MainActivity">

<Button
android:id="@+id/button"

android:layout_width="211dp"
android:layout_height="61dp"

android:text="Click here to continue"


android:textSize="16sp"
app:iconSize="28dp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.445"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.723" />

<TextView
android:id="@+id/textView2"

android:layout_width="328dp"
android:layout_height="84dp"
android:text=" SIDDAGANGA INSTITUTE OF"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:textColor="#000000"
android:textSize="24sp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.493"
app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.401" />

<TextView
android:id="@+id/textView3"

android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:text="TECHNOLOGY"
android:textColor="#000000"
android:textSize="24sp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.466"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.436" />

<TextView
android:id="@+id/textView4"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="An autonoumus institue affiliated to AICTE"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.499" />

<TextView

android:id="@+id/textView5"
android:layout_width="wrap_content"

android:layout_height="wrap_content"
android:layout_marginEnd="108dp"

android:text="B.H. Road, Tumkur - 572103"


android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.559" />

<ImageView

android:id="@+id/imageView"
android:layout_width="126dp"

android:layout_height="152dp"
android:layout_marginStart="128dp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintVertical_bias="0.131"
app:srcCompat="@drawable/img" />

</androidx.constraintlayout.widget.ConstraintLayout>

JAVA Code:

a) Direct method call:

package com.example.lab1;

import android.os.Bundle;

import android.view.View;
import android.widget.Button;

import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);
Button btn = findViewById(R.id.button);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

btn.setOnClickListener(new View.OnClickListener() {
@Override

public void onClick(View v) {


Toast.makeText(MainActivity. this, "welcome to mobile

application development laboratory",


Toast.LENGTH_SHORT).show();

}
});
}

b) Indirect method call:

package com.example.lab1;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.Toast;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

public void onClick(View v) {

Toast.makeText(MainActivity.this, "welcome to mobile

application development laboratory",

Toast.LENGTH_SHORT).show();

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-2: Create an application to design a Visiting Card. The Visiting card


should have a company logo at the top right corner. The company name should
be displayed in Capital letters, aligned to the centre. Information like the name of
the employee, job title, phone number, address, email, fax and the website
address are to be displayed. Insert a horizontal line between the job title and the
phone number.

XML Design:

1. Firstly, Create an Application by Name “VisitingCardApp”.


2. Go to xml code of design change the layout to “RelativeLayout”
3. Add TextView component change the following properties:
• Size: 21dp
• Text: SIDDAGANGA INSTITUTE OF TECHNOLOGY
• Align left top
4. Add ImageView to design and in type choose “IC_LAUNCHER_FOREGROUND”.
• Download the logo & copy the same in res->drawable folder.
• In xml code of imageview change srcCompat=”@drawable/logo”.
• Align right top
5. Add View component & change the following properties:
• Height: 4dp
• Background: “#4444”
6. Add TextView component change the following properties:
• Size: 20dp
• Text: RAMESH GOVIND
• Style: Bold
• Align center
7. Add TextView component change the following properties:
• Size: 18sp
• Text: Student-ISE
• Align center
8. Add TextView component change the following properties:
• Size: 16sp

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

• Text: Address: | Tumkur - 572103


• Align: center
9. Add TextView component change the following properties:
• Size: 15sp
• Text: rameshgovind17@gmail.com
• Align: center
10. Add TextView component change the following properties:
• Size: 15sp
• Text: Phone-9952698794

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#FDFBF7"

tools:context=".MainActivity">

<TextView

android:id="@+id/textView2"

android:layout_width="253dp"

android:layout_height="99dp"

android:text="SIDDAGANGA INSTITUTE OF TECHNOLOGY"

android:textAlignment="center"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:textSize="21dp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.101"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.166" />

<ImageView

android:id="@+id/imageView2"

android:layout_width="120dp"

android:layout_height="115dp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.945"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.121"

app:srcCompat="@drawable/logo" />

<View

android:id="@+id/view"

android:layout_width="412dp"

android:layout_height="235dp"

android:background="#4444"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="1.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.032" />

<TextView

android:id="@+id/textView3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="RAMESH GOVIND"

android:textAlignment="center"

android:textSize="20dp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.497"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.625" />

<TextView

android:id="@+id/textView4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:text="STUDENT - ISE"

android:textAlignment="center"

android:textSize="18dp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.467"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.684" />

<TextView

android:id="@+id/textView5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginEnd="52dp"

android:text="ADDRESS: B.H. ROAD | TUMKUR - 573102"

android:textAlignment="center"

android:textSize="16sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.757" />

<TextView

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:id="@+id/textView6"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Email -ID: rameshgovind17@sit.ac.in"

android:textAlignment="center"

android:textSize="15sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.798" />

<TextView

android:id="@+id/textView7"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Ph no.: 9952698794"

android:textAlignment="center"

android:textSize="15sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.476"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintVertical_bias="0.838" />

<ImageView

android:id="@+id/imageView3"

android:layout_width="103dp"

android:layout_height="148dp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.48"

app:srcCompat="@drawable/user" />

</androidx.constraintlayout.widget.ConstraintLayout>

JAVA Code:

package com.example.myapplication;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),

(v, insets) -> {

Insets systemBars = insets.getInsets(WindowInsetsCompat.

Type.systemBars());

v.setPadding(systemBars.left, systemBars.top, systemBars.right,

systemBars.bottom);

return insets;

});

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 9


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-3: Develop an Android application using controls like Button, TextView,


EditText for designing a calculator having basic functionality like Addition,
Subtraction, Multiplication, and Division.

XML Design:

1. Firstly, Create an Application by Name “calciApplication”.


2. Go to xml code of design change the layout to “RelativeLayout”.
3. Add TextView component & change the following properties:
• Size: 36sp
• Text: Simple Calci
• Center-Align
4. Add PlainText(EditText) component & change the following properties in XML Code:
• Text: “”
• Hint: “Enter the Number 1”
• id: “@+id/editText1”
5. Add PlainText(EditText) component & change the following properties in XML Code:
• Text: “”
• Hint: “Enter the Number 2 ”
• id: “@+id/editText2”
6. Add TextView component to display result & change the following properties:
• Size: 40dp
• Text: “0”
• Center-Align
• id: “@+id/tv1”
7. Add 4 Buttons & rename the four buttons “ADD”, “SUB”,”MUL” and “DIV” with following
addition:
• Onclick: “Add”(Add Button)
• Onclick: “Sub”(Sub Button)
• Onclick: “Mul”(Mul Button)
• Onclick: “Div”(Div Button)

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

XML Code:

<?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">

<TextView

android:layout_width="209dp"

android:layout_height="60dp"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="113dp"

android:layout_marginRight="113dp"

android:layout_marginBottom="610dp"

android:text="Simple Calci"

android:textSize="36sp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintLeft_toLeftOf="parent"

app:layout_constraintRight_toRightOf="parent"

app:layout_constraintTop_toTopOf="parent" />

<EditText

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:id="@+id/editText2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="117dp"

android:layout_marginRight="117dp"

android:layout_marginBottom="418dp"

android:ems="10"

android:hint="Enter the Number 2"

android:inputType="textPersonName"

android:text=""

android:textColorHighlight="#FFFFFF" />

<EditText

android:id="@+id/editText1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="116dp"

android:layout_marginRight="116dp"

android:layout_marginBottom="504dp"

android:ems="10"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:hint="Enter the Number 1"

android:inputType="textPersonName"

android:text=""

android:textColorHighlight="#FFFFFF" />

<Button

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="261dp"

android:layout_marginRight="261dp"

android:layout_marginBottom="213dp"

android:onClick="add"

android:text="ADD"

android:textStyle="bold"

app:backgroundTint="#E8F381" />

<Button

android:id="@+id/button3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="261dp"

android:layout_marginRight="261dp"

android:layout_marginBottom="105dp"

android:onClick="mul"

android:text="MUL"

app:backgroundTint="#A1FAA4" />

<Button

android:id="@+id/button4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="68dp"

android:layout_marginRight="68dp"

android:layout_marginBottom="107dp"

android:onClick="div"

android:text="DIV"

app:backgroundTint="#E6C28C" />

<Button

android:id="@+id/button2"

android:layout_width="wrap_content"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="70dp"

android:layout_marginRight="70dp"

android:layout_marginBottom="214dp"

android:onClick="sub"

android:text="SUB"

app:backgroundTint="#ECA9A9" />

<TextView

android:id="@+id/tv1"

android:layout_width="86dp"

android:layout_height="61dp"

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="144dp"

android:layout_marginRight="144dp"

android:layout_marginBottom="310dp"

android:text="0"

android:textSize="36sp" />

</RelativeLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:

package com.example.simplecalculator;

import android.os.Bundle;

import android.view.View;

import android.widget.EditText;

import android.widget.TextView;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

EditText e1,e2;

TextView tv;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

setContentView(R.layout.activity_main);

e1 =(EditText) findViewById(R.id.editText1);

e2 = (EditText)findViewById(R.id.editText2);

tv= (TextView) findViewById(R.id.tv1);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

public void add(View v)

int a1=Integer.parseInt(e1.getText().toString());

int a2=Integer.parseInt(e2.getText().toString());

int result=a1+a2;

tv.setText(""+result);

public void sub(View v){

int a1=Integer.parseInt(e1.getText().toString());

int a2= Integer.parseInt(e2.getText().toString());

int result=a1-a2;

tv.setText(""+result);

public void mul(View v){

int a1=Integer.parseInt(e1.getText().toString());

int a2= Integer.parseInt(e2.getText().toString());

int result=a1*a2;

tv.setText(""+result);

public void div(View v){

float a1=Integer.parseInt(e1.getText().toString());

float a2= Integer.parseInt(e2.getText().toString());

float result=a1/a2;

tv.setText(""+result);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 9


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-4(A): Develop an android application to demonstrate explicit intent.

1. FIRST ACTIVITY:

XML Design:

1. Firstly, Create an Application by Name “ExplicitApplication”.


2. Add TextView component & change the following properties:
• Size: 36sp
• Text: FIRST ACTIVITY
• Center-Align
3. Add Button component & change the following properties in XML.
• Id: “@+id/button”
• Text: “Click here to go to second activity”
• onClick: second

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout

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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<TextView

android:layout_width="wrap_content"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_height="wrap_content"

android:text="FIRST ACTIVITY"

android:textSize="34sp"

android:textStyle="italic"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.208" />

<Button

android:id="@+id/button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="first"

android:text="Click here to go to second activity"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.447"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.669" />

</androidx.constraintlayout.widget.ConstraintLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:

package com.example.intentapplication;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class secondactivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),

(v, insets) -> {

Insets systemBars =

insets.getInsets(WindowInsetsCompat.Type.systemBars());

v.setPadding(systemBars.left, systemBars.top, systemBars.right,

systemBars.bottom);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

return insets;

});

public void first(View view2)

Intent intent1 = new

Intent(getApplicationContext(),secondactivity.class);

startActivity(intent1);

2. SECOND ACTIVITY:
XML Design:

1. Firstly, Create an Application by Name “ExplicitApplication”.


2. Right click on Java folder-> new-> activity->empty activity-> name it as “secondactivity”
3. Add TextView component & change the following properties:
• Size: 36sp
• Text: SECOND ACTIVITY
• Center-Align
4. Add Button component & change the following properties in XML.
• Id: “@+id/button”
• Text: “Click here to go to first activity”
• onClick: second

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout

xmlns:android="http://schemas.android.com/apk/res/android"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".secondactivity">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="SECOND ACTIVITY"

android:textSize="34sp"

android:textStyle="italic"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.208" />

<Button

android:id="@+id/button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="first"

android:text="Click here to go to first activity"

app:layout_constraintBottom_toBottomOf="parent"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.447"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.669" />

</androidx.constraintlayout.widget.ConstraintLayout>

JAVA Code:
package com.example.intentapplication;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class secondactivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

setContentView(R.layout.activity_second);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),

(v, insets) -> {

Insets systemBars =

insets.getInsets(WindowInsetsCompat.Type.systemBars());

v.setPadding(systemBars.left, systemBars.top, systemBars.right,

systemBars.bottom);

return insets;

});

public void first(View view2)

Intent intent1 = new

Intent(getApplicationContext(),MainActivity.class);

startActivity(intent1);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-4(B): Develop an android application to demonstrate implicit intent.

XML Design:

1. Firstly, Create an Application by Name “ImplicitApplication”.


2. Add TextView component & change the following properties:
• Size: 36sp
• Text: SIDDAGANGA INSTITUTE OF TECHNOLOGY
• Center-Align
3. Add ImageView to design and in type choose “IC_LAUNCHER_FOREGROUND”.
• Download the logo & copy the same in res->drawable folder.
• In xml code of imageview change srcCompat=”@drawable/logo”.
• Align right top
4. Add TextView component change the following properties:
• Size: 16sp
• Text: “An autonomous institute affiliated to AICTE”
• Align center.
5. Add TextView component change the following properties:
• Size: 16sp
• Text: “B.H. Road, Tumkur – 572103”
• Align center.
6. Add Button component & change the following properties in XML.
• Id: “@+id/button1”
• Text: “Contineo”
• onClick: Contineo
7. Add Button component & change the following properties in XML.
• Id: “@+id/button2”
• Text: “Contact”
• onClick: telephone
8. Add Button component & change the following properties in XML.
• Id: “@+id/button2”
• Text: “Visit website”
• onClick: website

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

9. Add Button component & change the following properties in XML.


• Id: “@+id/button2”
• Text: “Location”
• onClick: location
10. Add TextView component change the following properties:
• Size: 16sp
• Text: “E-mail: principal@sit.ac.in”
• Align center.
11. Add TextView component change the following properties:
• Size: 16sp
• Text: "ph no: + 91 816 - 2282994"
• Align center.

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<TextView

android:id="@+id/textView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:text="SIDDAGANGA INSTITUTE OF TECHNOLOGY"

android:textAlignment="center"

android:textColor="#A116BA"

android:textSize="24sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.311" />

<ImageView

android:id="@+id/imageView"

android:layout_width="146dp"

android:layout_height="146dp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.498"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.068"

app:srcCompat="@drawable/logo" />

<TextView

android:id="@+id/textView2"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="An Autonomous institution affiliated to VTU, Belagavi"

android:textColor="#000000"

android:textSize="14sp"

android:textStyle="normal"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.405" />

<TextView

android:id="@+id/textView3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="B.H Road, Tumkur - 572103"

android:textAlignment="center"

android:textColor="#000000"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.456" />

<Button

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="contineo"

android:text="Contineo"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.498"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.549" />

<Button

android:id="@+id/button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="telephone"

android:text="Contact"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.498"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.824" />

<Button

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:id="@+id/button3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="website"

android:text="Visit website"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.498"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.641" />

<TextView

android:id="@+id/textView4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="E-mail: principal@sit.ac.in"

android:textColor="#000000"

android:textStyle="normal"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.505"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.917" />

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

<TextView

android:id="@+id/textView5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="ph no: + 91 816 - 2282994"

android:textColor="#000000"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.96" />

<Button

android:id="@+id/button4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="location"

android:text="Location"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.495"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.733" />

</androidx.constraintlayout.widget.ConstraintLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:

package com.example.implicitintentapplication;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.view.View;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

import java.util.Locale;

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets) -> {

Insets systemBars =

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

insets.getInsets(WindowInsetsCompat.Type.systemBars());

v.setPadding(systemBars.left, systemBars.top, systemBars.right,

systemBars.bottom);

return insets;

});

public void contineo(View v1)

Uri webpage =

Uri.parse("https://www.bing.com/ck/a?!&&p=805a898862d5c926JmltdHM9MTcxNjQyMjQ

wMCZpZ3VpZD0wZWZjZjZhYS0yYWJlLTZkN2EtMDQxZC1lNTQyMmI3NzZjNTAmaW5zaWQ9NTIzOA&p

tn=3&ver=2&hsh=3&fclid=0efcf6aa-2abe-6d7a-041d-

e5422b776c50&psq=sit+tumkur+contineo&u=a1aHR0cHM6Ly9zaW1zLnNpdC5hYy5pbi9wYXJl

bnRzLw&ntb=1");

Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);

startActivity(webIntent);

public void website(View v1)

Uri webpage =

Uri.parse("https://www.bing.com/ck/a?!&&p=53952f5ebf9b4deeJmltdHM9MTcxNjQyMjQ

wMCZpZ3VpZD0wZWZjZjZhYS0yYWJlLTZkN2EtMDQxZC1lNTQyMmI3NzZjNTAmaW5zaWQ9NTI0Mg&p

tn=3&ver=2&hsh=3&fclid=0efcf6aa-2abe-6d7a-041d-

e5422b776c50&psq=sit+tumkur+&u=a1aHR0cDovL3d3dy5zaXQuYWMuaW4vaHRtbC9ob21lLmh0

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 9


MOBILE APPLICATION DEVELOPMENT S4ISA02

bWw&ntb=1");

Intent webIntent1 = new Intent(Intent.ACTION_VIEW, webpage);

startActivity(webIntent1);

public void telephone(View v3)

String phoneNumber = "+ 91 816 - 2282696";

Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" +

phoneNumber));

startActivity(callIntent);

public void location(View v4){

String address = "SIDDAGANGA INSTITUTE OF TECHNOLOGY, TUMKUR";

String geoUri = String.format(Locale.ENGLISH, "geo:0,0?q=%s",

Uri.encode(address));

Intent intentWithAddress = new Intent(Intent.ACTION_VIEW,


Uri.parse(geoUri));

startActivity(intentWithAddress);

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 10


MOBILE APPLICATION DEVELOPMENT S4ISA02

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 11


MOBILE APPLICATION DEVELOPMENT S4ISA02

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 12


MOBILE APPLICATION DEVELOPMENT S4ISA02

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 13


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-5: Create a SIGNUp activity with Username and Password. Validation of


password should happen based on the following rules:

• Password should contain uppercase and lowercase letters.

• Password should contain letters and numbers.

• Password should contain special characters.

• Minimum length of the password (the default value is 8).

On successful SIGN UP proceed to the next Login activity. Here the user should
SIGN IN using the Username and Password created during signup activity. If the
Username and Password are matched, then navigate to the next activity which
displays a message saying, “Successful Login” or else display a toast message
saying “Login Failed”. The user is given only two attempts and after that display a
toast message saying, “Failed Login Attempts” and disable the SIGN IN button.
Use Bundle to transfer information from one activity to another.

1. SIGNUP ACTIVITY:

XML Design:

1. Firstly, Create an Application by Name “SignUpApplication”.


2. Add View component & change the following properties:
• Background: #DDB375
• Height: 731dp
3. Add TextView component & change the following properties:
• Size: 24sp
• Text: “Sign Up”
• Center-Align
4. Add Email (EditText) component & change the following properties in XML Code:
• Hint: “E-mail”
• id: “@+id/editTextEmailAddress”
5. Add Password (EditText) component & change the following properties in XML Code:
• Hint: “Password”

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

• id: “@+id/ editTextPassword”


6. Add Button component & change the following properties in XML code:
• Id: “@+id/Button”
• Text: “Sign in”

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout

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">

<View

android:id="@+id/view"

android:layout_width="412dp"

android:layout_height="731dp"

android:background="#DDB375"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.0"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

<TextView

android:id="@+id/textView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginTop="112dp"

android:elegantTextHeight="true"

android:hint="E-mail"

android:text="SignUP"

android:textColor="#0419DA"

android:textSize="34sp"

android:textStyle="bold|italic"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.483"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="@+id/view"

app:layout_constraintVertical_bias="0.012" />

<EditText

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:id="@+id/editTextEmailAddress"

android:layout_width="263dp"

android:layout_height="59dp"

android:ems="10"

android:hint="E-mail"

android:inputType="textEmailAddress"

android:textColorHint="#000000"

app:layout_constraintBottom_toBottomOf="@+id/view"

app:layout_constraintEnd_toEndOf="@+id/view"

app:layout_constraintHorizontal_bias="0.489"

app:layout_constraintStart_toStartOf="@+id/view"

app:layout_constraintTop_toTopOf="@+id/view"

app:layout_constraintVertical_bias="0.386" />

<EditText

android:id="@+id/editTextPassword"

android:layout_width="264dp"

android:layout_height="54dp"

android:ems="10"

android:hint="Password"

android:inputType="textPassword"

android:textColorHint="#000000"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="@+id/view"

app:layout_constraintHorizontal_bias="0.479"

app:layout_constraintStart_toStartOf="@+id/view"

app:layout_constraintTop_toTopOf="@+id/view"

app:layout_constraintVertical_bias="0.515" />

<Button

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Sign in"

android:textSize="16sp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.466"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.714" />

</androidx.constraintlayout.widget.ConstraintLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:

package com.example.signup;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.Toast;

import androidx.activity.EdgeToEdge;

import androidx.annotation.NonNull;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

import java.util.regex.Pattern;

public class MainActivity extends AppCompatActivity {

EditText email_sign, password_sign;

Button signupbtn;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

email_sign = (EditText) findViewById(R.id.editTextEmailAddress);

password_sign = (EditText) findViewById(R.id.editTextPassword);

signupbtn = (Button) findViewById(R.id.button);

signupbtn.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String email = email_sign.getText().toString();

String password = password_sign.getText().toString();

if (!isValidPassword(password)) {

Toast.makeText(MainActivity.this, "Password doesn't match


rules", Toast.LENGTH_SHORT).show();

return;

Intent i = new Intent


(getApplicationContext(),login_activity.class);

i.putExtra("email", email);

i.putExtra("password", password);

startActivity(i);

});

Pattern lowerCase = Pattern.compile("^.[a-z].$");

Pattern upperCase = Pattern.compile("^.[A-Z]. $");

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

Pattern number = Pattern.compile("^.[0-9].$");

Pattern special_char = Pattern.compile("^.[a-zA-Z0-9].$");

private Boolean isValidPassword(String password)

if(password.length()<8)

return false;

if(!lowerCase.matcher(password).matches())

return false;

if(!upperCase.matcher(password).matches())

return false;

if(!number.matcher(password).matches())

return false;

if(!special_char.matcher(password).matches())

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

return false;

return true;

2. LOGIN ACTIVITY:
XML Design:

1. Right click on Java folder-> new-> activity->empty activity-> name it as “login_Activity”.


2. Add View component & change the following properties:
• Background: #DDB375
• Height: 731dp
3. Add TextView component & change the following properties:
• Size: 38dp
• Text: “Login”
• Center-Align
4. Add Email (EditText) component & change the following properties in XML Code:
• Hint: “E-mail”
• id: “@+id/editTextTextEmailAddress2”
5. Add Password (EditText) component & change the following properties in XML Code:
• Hint: “Password”
• id: “@+id/ editTextTextPassword2”
6. Add Button component & change the following properties in XML Code:
• Id: “@+id/button2”
• Text: “Login”

XML Code:

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

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 9


MOBILE APPLICATION DEVELOPMENT S4ISA02

<androidx.constraintlayout.widget.ConstraintLayout

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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".login_activity">

<View

android:id="@+id/view2"

android:layout_width="412dp"

android:layout_height="732dp"

android:background="#DDB375"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

<TextView

android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Login"

android:textColor="#0419DA"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 10


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:textSize="34sp"

android:textStyle="bold|italic"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.463"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.151" />

<EditText

android:id="@+id/editTextTextEmailAddress2"

android:layout_width="257dp"

android:layout_height="53dp"

android:ems="10"

android:hint="E-mail"

android:inputType="textEmailAddress"

android:textColorHint="#000000"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.506"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.383" />

<EditText

android:id="@+id/editTextTextPassword2"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 11


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_width="259dp"

android:layout_height="54dp"

android:ems="10"

android:hint="Password"

android:inputType="textPassword"

android:textColorHint="#000000"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="@+id/view2" />

<Button

android:id="@+id/button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Login"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.498"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.688" />

</androidx.constraintlayout.widget.ConstraintLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 12


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:
package com.example.signup;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.Toast;

import androidx.activity.EdgeToEdge;

import androidx.annotation.NonNull;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class login_activity extends AppCompatActivity {

EditText emailEditText, passwordEditText;

Button login_btn;

int counter=2;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 13


MOBILE APPLICATION DEVELOPMENT S4ISA02

EdgeToEdge.enable(this);

setContentView(R.layout.activity_login);

emailEditText=(EditText)findViewById(R.id.editTextTextEmailAddress2);

passwordEditText=(EditText)findViewById(R.id.editTextTextPassword2);

login_btn=(Button)findViewById(R.id.button2);

String registeredEmail=getIntent().getStringExtra("email");

String registeredpassword=getIntent().getStringExtra("password");

login_btn.setOnClickListener(new View.OnClickListener()

@Override

public void onClick(View v)

String email=emailEditText.getText().toString();

String password=passwordEditText.getText().toString();

if(registeredEmail.equals(email) &&

registeredpassword.equals(password))

Intent i = new

Intent(getApplicationContext(),loginsuccessful_activity.class);

startActivity(i);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 14


MOBILE APPLICATION DEVELOPMENT S4ISA02

else

Toast.makeText(login_activity.this, "Invalid

Credentials", Toast.LENGTH_SHORT).show();

counter--;

if(counter==0)

Toast.makeText(login_activity.this, "Failed to login",

Toast.LENGTH_SHORT).show();

login_btn.setEnabled(false);

});

3. LOGIN SUCCESSFUL ACTIVITY:


XML Design:

1. Right click on Java folder-> new-> activity->empty activity-> name it as “loginSuccessful_activity”.


2. Go to xml code of design change the layout to “RelativeLayout”.
3. Add ImageView to design and in type choose “IC_LAUNCHER_FOREGROUND”
• Download the logo & copy the same in res->drawable folder
• In xml code of imageview change srcCompat=”@drawable/logo”
• Align right top
4. Add TextView component & change the following properties:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 15


MOBILE APPLICATION DEVELOPMENT S4ISA02

• Size: 38dp
• Text: “Login Successful”
• Center-Align

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout

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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#05CEE8"

tools:context=".loginsuccessful_activity">

<View

android:id="@+id/view3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#DFE69B"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="1.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.0" />

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 16


MOBILE APPLICATION DEVELOPMENT S4ISA02

<TextView

android:id="@+id/textView3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Login Successful"

android:textColor="#000000"

android:textSize="34sp"

android:textStyle="bold|italic"

app:layout_constraintBottom_toBottomOf="@+id/view3"

app:layout_constraintEnd_toEndOf="@+id/view3"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="@+id/view3" />

<ImageView

android:id="@+id/imageView"

android:layout_width="259dp"

android:layout_height="177dp"

app:layout_constraintBottom_toBottomOf="@+id/view3"

app:layout_constraintEnd_toEndOf="@+id/view3"

app:layout_constraintHorizontal_bias="0.519"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="@+id/view3"

app:layout_constraintVertical_bias="0.258"

app:srcCompat="@drawable/logo" />

</androidx.constraintlayout.widget.ConstraintLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 17


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:

package com.example.signup;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

public class loginsuccessful_activity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_loginsuccessful);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets) -> {

Insets systemBars =

insets.getInsets(WindowInsetsCompat.Type.systemBars());

v.setPadding(systemBars.left, systemBars.top, systemBars.right,


systemBars.bottom);

return insets;

});

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 18


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 19


MOBILE APPLICATION DEVELOPMENT S4ISA02

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 20


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-6: Develop an application to set an image as wallpaper. On click of a


button, the wallpaper image should start to change randomly every 30 seconds.

XML Design:

1. Firstly, Create an Application by Name “WallpaperActivity”.


2. Go to xml code of design change the layout to “RelativeLayout”.
3. Add TextView component & change the following properties:
• Size: 38dp
• Text: Wall Paper Change Application
• Center-Align
4. Add Button component & change the following properties:
• Size: 38dp
• Text: Click Here To Change Wall Paper
5. Save five images (jpg format) in the drawable folder. In this, i1.jpg, i2.jpg, i3.jpg and i4.jpg image.

XML Code:

<?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">

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_alignParentEnd="true"

android:layout_alignParentRight="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="142dp"

android:layout_marginRight="142dp"

android:layout_marginBottom="287dp"

android:text="CLICK HERE" />

<TextView

android:id="@+id/textView"

android:layout_width="319dp"

android:layout_height="wrap_content"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginStart="49dp"

android:layout_marginTop="93dp"

android:layout_marginEnd="43dp"

android:layout_marginBottom="460dp"

android:text="Wallpaper Change Application"

android:textAlignment="center"

android:textColor="#000000"

android:textSize="38dp" />

</RelativeLayout>

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

JAVA Code:

package com.example.myapplication;

import android.app.WallpaperManager;

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.Toast;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

import java.io.IOException;

import java.util.Timer;

import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

Button wallpaperChange;

Timer mytimer;

Drawable drawable;

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

WallpaperManager wpm;

int prev=1;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

mytimer=new Timer();

wpm = WallpaperManager.getInstance(this);

wallpaperChange=(Button)findViewById(R.id.button1);

wallpaperChange.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

setwallpaper();

});

private void setwallpaper() {

Toast.makeText(this,"setting Wallpaper please

wait.",Toast.LENGTH_LONG).show();

mytimer.schedule(new TimerTask() {

@Override

public void run()

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

if(prev==1) {

drawable = getResources().getDrawable(R.drawable.i1);

prev = 2;

else if(prev==2) {

drawable = getResources().getDrawable(R.drawable.i1);

prev=3;

else if(prev==3) {

drawable = getResources().getDrawable(R.drawable.i3);

prev=4;

else if(prev==4) {

drawable = getResources().getDrawable(R.drawable.i4);

prev=1;

Bitmap wallpaper = ((BitmapDrawable)drawable).getBitmap();

try {

wpm.setBitmap(wallpaper);

catch(IOException e)

e.printStackTrace();

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

},0,30000);

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-7: Write a program to create an activity with two buttons START and
STOP. On pressing of the START button, the activity must start the counter by
displaying the numbers from One and the counter must keep on counting until
the STOP button is pressed. Display the counter value in a TextView control.

XML Design:

1. Firstly, Create an Application by Name “CounterActivity”.


2. Add View component & change the following properties:
• Background: #DDB375
• Height: 51dp
3. Add TextView component & change the following properties:
• Text: “Counter Application”
• Center-Align
4. Add TextView component & change the following properties:
• Text: “0”
5. Add Button components & change the following properties:
• Text: START
• id: “@+id/button”
6. Add Button components & change the following properties:
• Text: STOP
• id: “@+id/button2”

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout

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:id="@+id/main"

android:layout_width="match_parent"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_height="match_parent"

tools:context=".MainActivity">

<View

android:id="@+id/view"

android:layout_width="match_parent"

android:layout_height="207dp"

android:background="#BF8126"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.0" />

<TextView

android:id="@+id/textView"

android:layout_width="325dp"

android:layout_height="wrap_content"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:layout_alignParentEnd="true"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_alignParentBottom="true"

android:text="COUNTER APPLICATION"

android:textAlignment="center"

android:textSize="28sp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.113" />

<Button

android:id="@+id/button2"

android:layout_width="101dp"

android:layout_height="wrap_content"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:text="STOP"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.822"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.774" />

<Button

android:id="@+id/button"

android:layout_width="103dp"

android:layout_height="wrap_content"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:text="START"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.191"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintVertical_bias="0.774" />

<TextView

android:id="@+id/textView2"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_width="wrap_content"

android:layout_height="52dp"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:text="0"

android:textAlignment="center"

android:textColor="#000000"

android:textSize="24sp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

JAVA Code:

package com.example.counterapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

import android.os.Handler;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

TextView txtCounter;

Button btn_start,btn_stop;

int count=0;

Handler customHandler=new Handler();

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

txtCounter= (TextView)findViewById(R.id.textView2);

btn_start =(Button)findViewById(R.id.button);

btn_stop=(Button)findViewById(R.id.button2);

btn_start.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

customHandler.postDelayed(updateTimerThread,0);

});

btn_stop.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

customHandler.removeCallbacks(updateTimerThread);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

});

private final Runnable updateTimerThread =new Runnable() {

@Override

public void run() {

txtCounter.setText(""+count);

customHandler.postDelayed(this,1000);

count++;

};

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-8: Create an activity like a phone dialler with CALL and SAVE buttons. On
pressing the CALL button, it must call the phone number and on pressing the
SAVE button it must save the number to the phone contacts.

XML Design:

1. Firstly, Create an Application by Name “CallActivity”.


2. Go to xml code of design change the layout to “RelativeLayout”.
3. Add TextView component & change the following properties:
• Size: 24sp
• Text: Call and Save Application
• Center-Align
4. Add EditText component & change the following properties in XML Code:
• id: “@+id/phoneNumberEditText”
5. Add PlainText(EditText) component & change the following properties in XML Code:
• Text: “”
• Hint: “Copied Text”
• id: “@+id/editText2”
6. Add three buttons to the design & change the textof the Buttons to “Clear”, “Call”, “Save” and
change the id as follows:
• id:”@+id/clearBtn”
• id:”@+id/callBtn”
• id:”@+id/saveBtn”
7. Add twelve buttons to the design & change the text of the Buttons as 1,2,3,4,5,6,7,8,9,0,*,#

XML Code:

<?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:id="@+id/Button11"

android:layout_width="match_parent"

android:layout_height="match_parent"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:backgroundTint="#4CAF50"

tools:context=".MainActivity">

<Button

android:id="@+id/button8"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="168dp"

android:layout_marginBottom="237dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="8" />

<Button

android:id="@+id/Button10"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="286dp"

android:layout_marginBottom="163dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="*" />

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

<Button

android:id="@+id/saveBtn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="101dp"

android:layout_marginBottom="51dp"

android:backgroundTint="#CDDC39"

android:text="Save" />

<Button

android:id="@+id/callBtn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="223dp"

android:layout_marginBottom="52dp"

android:backgroundTint="#F44336"

android:text="Call" />

<Button

android:id="@+id/clearBtn12"

android:layout_width="wrap_content"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="168dp"

android:layout_marginBottom="162dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="0" />

<Button

android:id="@+id/Button7"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="286dp"

android:layout_marginBottom="236dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="7" />

<Button

android:id="@+id/Button9"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_alignParentBottom="true"

android:layout_marginEnd="49dp"

android:layout_marginBottom="236dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="9" />

<EditText

android:id="@+id/phoneNumberEditText"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="163dp"

android:layout_marginBottom="560dp"

android:ems="10"

android:hint="Phone Number"

android:inputType="phone"

android:onClick="inputNumber" />

<Button

android:id="@+id/clearBtn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 5


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:layout_marginEnd="48dp"

android:layout_marginBottom="558dp"

android:backgroundTint="#E91E63"

android:text="Clear" />

<Button

android:id="@+id/Button12"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="49dp"

android:layout_marginBottom="162dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="#" />

<Button

android:id="@+id/Button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="288dp"

android:layout_marginBottom="399dp"

android:backgroundTint="#4CAF50"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 6


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:onClick="inputNumber"

android:text="1" />

<Button

android:id="@+id/Button4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="287dp"

android:layout_marginBottom="313dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="4" />

<Button

android:id="@+id/Button5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="168dp"

android:layout_marginBottom="313dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="5" />

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 7


MOBILE APPLICATION DEVELOPMENT S4ISA02

<Button

android:id="@+id/Button6"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="48dp"

android:layout_marginBottom="313dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="6" />

<Button

android:id="@+id/Button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="170dp"

android:layout_marginBottom="398dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="2" />

<Button

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 8


MOBILE APPLICATION DEVELOPMENT S4ISA02

android:id="@+id/Button3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginEnd="49dp"

android:layout_marginBottom="399dp"

android:backgroundTint="#4CAF50"

android:onClick="inputNumber"

android:text="3" />

<TextView

android:id="@+id/textView"

android:layout_width="305dp"

android:layout_height="47dp"

android:layout_alignParentStart="true"

android:layout_alignParentTop="true"

android:layout_alignParentEnd="true"

android:layout_alignParentBottom="true"

android:layout_marginStart="46dp"

android:layout_marginTop="35dp"

android:layout_marginEnd="59dp"

android:layout_marginBottom="648dp"

android:text="Call and Save Application"

android:textAlignment="center"

android:textSize="24sp" />

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 9


MOBILE APPLICATION DEVELOPMENT S4ISA02

</RelativeLayout>

JAVA Code:

package com.example.callandsaveapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.provider.ContactsContract;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

EditText phoneNumberEditText;

Button clearBtn, saveBtn, callBtn;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

phoneNumberEditText = findViewById(R.id.phoneNumberEditText);

clearBtn = findViewById(R.id.clearBtn);

callBtn = findViewById(R.id.callBtn);

saveBtn = findViewById(R.id.saveBtn);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 10


MOBILE APPLICATION DEVELOPMENT S4ISA02

clearBtn.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

phoneNumberEditText.setText("");

});

callBtn.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String phoneNumber =

phoneNumberEditText.getText().toString();

Intent intent = new Intent(Intent.ACTION_DIAL);

intent.setData(Uri.parse("tel:" + phoneNumber));

startActivity(intent);

});

saveBtn.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String phoneNumber =

phoneNumberEditText.getText().toString();

Intent intent = new Intent(Intent.ACTION_INSERT);

intent.setType(ContactsContract.Contacts.CONTENT_TYPE);

intent.putExtra(ContactsContract.Intents.Insert.PHONE,
phoneNumber);

startActivity(intent);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 11


MOBILE APPLICATION DEVELOPMENT S4ISA02

});

public void inputNumber(View v) {

Button btn = (Button) v;

String digit = btn.getText().toString();

String phoneNumber = phoneNumberEditText.getText().toString();

phoneNumberEditText.setText(phoneNumber + digit);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 12


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 13


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-9: Write an android program to demonstrate scroll view and list view.
(List view should array adapter. The adapter should use array list of companies.
Each item in the list view should have company name, company address and its
annual revenue.)

XML Design:

1. Firstly, Create an Application by Name “ScrollApplication”.


2. Add ListView component & change the following properties:
• id: listview

XML Code:

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

<androidx.constraintlayout.widget.ConstraintLayout

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:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<ListView

android:id="@+id/listview"

android:layout_width="409dp"

android:layout_height="729dp"

app:layout_constraintBottom_toBottomOf="parent"

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

JAVA Code:

package com.example.scrollapplication;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.AdapterView;

import android.widget.ArrayAdapter;

import android.widget.ListView;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

String fruits[] = {

"LIST OF COMPANIES:",

"Name: Walmart\nAddress: Bentonville, Arkansas\nRevenue: $611,289


million",

"Name: Amazon\nAddress: Seattle, Washington\nRevenue: $513,983


million",

"Name: ExxonMobil\nAddress: Spring, Texas\nRevenue: $413,680


million",

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

"Name:Apple\nAddress: Cupertino, California\nRevenue: $394,328

million",

"Name: UnitedHealth Group\nAddress: Minnetonka,

Minnesota\nRevenue: $324,162 million",

"Name: CVS Health\nAddress: Woonsocket, Rhode Island\nRevenue:

$322,467 million",

"Name: Berkshire Hathaway\nAddress: Omaha, Nebraska\nRevenue:

$302,089 million",

"Name: Alphabet\nAddress: Mountain View, California\nRevenue:

$282,836 million",

"Name: McKesson Corporation\nAddress: Irving, Texas\nRevenue:

$276,711 million",

"Name: Chevron Corporation\nAddress: San Ramon,

California\nRevenue: $246,252 million"

};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

EdgeToEdge.enable(this);

setContentView(R.layout.activity_main);

ListView listView = findViewById(R.id.listview);

ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this,

android.R.layout.simple_list_item_1, fruits);

listView.setAdapter(arrayAdapter);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{

@Override

public void onItemClick(AdapterView<?> parent, View view, int

position, long id) {

Log.i("List_View", "Item is clicked @position " + position);

});

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4


MOBILE APPLICATION DEVELOPMENT S4ISA02

Program-10: Write an android program to display different shapes.

XML Design:

1. Firstly, Create an Application by Name “ShapesApplication”.


2. Go to xml code of design change the layout to “RelativeLayout”.
3. Add ImageView component & change the following properties:
• id: imageView

XML Code:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent">

<ImageView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:id="@+id/imageView" />

</RelativeLayout>

JAVA Code:
package com.example.scrollapplication;

import android.content.Context;

import android.graphics.Canvas;

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 1


MOBILE APPLICATION DEVELOPMENT S4ISA02

import android.graphics.Paint;

import android.os.Bundle;

import android.view.View;

import androidx.activity.EdgeToEdge;

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;

import androidx.core.view.ViewCompat;

import androidx.core.view.WindowInsetsCompat;

import android.app.Activity;

import android.graphics.Bitmap;

import android.graphics.Canvas;

import android.graphics.Color;

import android.graphics.Paint;

import android.graphics.drawable.BitmapDrawable;

import android.os.Bundle;

import android.widget.ImageView;

public class MainActivity extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 2


MOBILE APPLICATION DEVELOPMENT S4ISA02

ImageView i = (ImageView) findViewById(R.id.imageView);

i.setBackgroundDrawable(new BitmapDrawable(bg));

Canvas canvas = new Canvas(bg);

Paint paint = new Paint();

paint.setColor(Color.BLUE);

paint.setTextSize(50);

canvas.drawText("Rectangle", 420, 150, paint);

canvas.drawRect(400, 200, 650, 700, paint);

canvas.drawText("Circle", 120, 150, paint);

canvas.drawCircle(200, 350, 150, paint);

canvas.drawText("Square", 120, 800, paint);

canvas.drawRect(50, 850, 350, 1150, paint);

canvas.drawText("Line", 480, 800, paint);

canvas.drawLine(520, 850, 520, 1150, paint);

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 3


MOBILE APPLICATION DEVELOPMENT S4ISA02

Output:

4th Semester, Dept. of ISE, SIT Tumkur 2023-24 4

You might also like