0% found this document useful (0 votes)
51 views48 pages

MAD Lab Manual (A)

Uploaded by

Krish
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)
51 views48 pages

MAD Lab Manual (A)

Uploaded by

Krish
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/ 48

SAL College of Engineering

CE Department

Mobile Application Development (3170726)

Laboratory Manual

Year: 2024-2025

Student Name :
Enrollment No.:
INDEX

Sr. Page No.


Practical Date Marks Sign
No. From To
Introduction to Android Programming
1. and installation of Android Studio.
Write an Android application for ‘Hello
2. Student’s Name, Welcome to Android
Lab’.
Write an Android application to make a
3. Button to open a new activity from
another activity using Intent.
Implement following layouts:
1. Linear Layout
4.
2. Relative Layout
3. Table Layout
Design Login activity and implement
5. control events: Use EditText, Checkbox
and Buttons.
Create a Recycler View and list the
details of student using following fields:
1. Name
6.
2. Address
3. Photo (Image)
4. Delete (Button Operation).
Write an android application to insert
Customer Details (cID, cName,
7.
cOrderID) in SQLite Database in
Android.
Write an Android application that creates
8. a simple Dialog box with only 1 botton.

Using location service get the current


9. location and display in TextView.

10. Display the use of animations.

11. Create Notification for your application.


Experiment No: 1 Date: / /

TITLE: Introduction to Android Programming and installation of Android Studio.


OBJECTIVES:
To study about procedure of installing Android Studio and environment required to install its tools.

THEORY:
Steps to Install Android Studio:
Step: 1 Android Environment must require jdk. So install jdk. after installation we have to set a path.
Select Start menu > Computer > System Properties > Advanced System Properties. Then
open Advanced tab > Environment Variables, add new system variable JAVA_HOME that points to
your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.

Figure
Step: 2 Let's launch Android Studio.exe,Make sure before launch Android Studio, Our Machine should
require installed Java JDK. To install Java JDK,take a references of Android environment setup.

Step: 3 Once you launched Android Studio, it’s time to mention JDK5 path or later version in android
studio installer.
Step: 4 Below the image initiating JDK to android SDK

Step: 5 Need to check the components, which are required to create applications, below the image has
selected Android Studio,AndroidSDK,Android Virtual Machine and performance(Intel chip).

Step: 6 Need to specify the location of local machine path for Android studio and Android SDK, below
the image has taken default location of windows 8.1 x64 bit architecture.
Step: 7 Need to specify the ram space for Android emulator by default it would take 512MB of local
machine RAM.

Step: 8 At final stage, it would extract SDK packages into our local machine, it would take a while time
to finish the task and would take approximate 3 to 4 GB of Hard disk space.

Step: 9 After done all above steps perfectly, you must get finish button and it going to be open android
studio project with Welcome to android studio message as shown below.
Step: 10 You can start your application development by calling start a new android studio project. In a
new installation frame should ask Application name, package information and location of the project.

Figure: Android device targeted

Figure: Add activity to mobile


Figure: customize the activity

Figure: android studio home page


EXCERCISE:
1) Introduction to Android Programming and installation of Android Studio.

QUIZ:
Answer the Followings:

1) What is SDK?

➢ SDK or Software Development Kit is a complete collection of software tools and programs usually
offered by hardware and software suppliers. SDKs are used by developers to create applications
that are appropriate to specific platforms, such as operating systems or frameworks. An SDK’s
primary objective is to provide developers with a ready-made set of resources that simplify and
speed up the application development process.
EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 2 Date: / /

TITLE: Write an Android application for ‘Hello Student’s Name, Welcome to Android Lab’.
CODE:
activity_main.xml
<?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="#FFEB3B"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello Aaryan ! Welcome to Android Lab"
android:textAlignment="center"
android:textColor="#437FAF"
android:textSize="48sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
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 {

@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;
});
}
}
OUTPUT:

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3) (3)

Signature with date:


Experiment No: 3 Date: / /

TITLE: Write an Android application to make a Button to open a new activity from another
activity using Intent.
CODE:
activity_main.xml

<?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"
android:layout_height="wrap_content"
android:text="Activity1"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:textSize="20dp"
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.65" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

package com.example.intent;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


private View move;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

move= findViewById(R.id.button1);

move.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent intent = new Intent(MainActivity.this, MainActivity2.class);


startActivity(intent);
}
});
}
}

OUTPUT:

Activity 1
Activity 2

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 4 Date: / /

TITLE: Implement following layouts:


1. Linear Layout
2. Relative Layout
3. Table Layout
CODE:
1. Linear Layout
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:background="#C7B6E7"
android:id="@+id/main"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Login"
android:textColor="#1B2E9D"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.147" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username :"
android:textColor="#1B2E9D"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.132"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.308" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password :"
android:textColor="#1B2E9D"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.132"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.401" />

<EditText
android:id="@+id/editText"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="enter your name"
tools:ignore="TouchTargetSizeCheck"

tools:layout_editor_absoluteX="151dp"
tools:layout_editor_absoluteY="207dp" />

<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="password"
tools:layout_editor_absoluteX="151dp"
tools:layout_editor_absoluteY="273dp" />

<Button
android:id="@+id/button"
android:layout_width="156dp"
android:layout_height="59dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="#8163B6"
android:text="Login"
android:textColor="@color/white"
android:textColorHighlight="#FBFBFB"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText2"
app:layout_constraintVertical_bias="0.126" />
</LinearLayout>
MainActivity.java

package com.example.linearlayout;

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 {

@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;
});
}
}

OUTPUT:
2. Relative Layout
activity_main.xml
<?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:id="@+id/main"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="500dp"
android:layout_marginBottom="539dp"
android:text="Username :"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.132"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.308" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="500dp"
android:layout_marginBottom="459dp"
android:text="Password :"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.132"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.401" />
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="257dp"
android:layout_marginBottom="532dp"
android:ems="10"
android:inputType="textPersonName"
android:text="enter your name"
tools:ignore="TouchTargetSizeCheck"
tools:layout_editor_absoluteX="151dp"
tools:layout_editor_absoluteY="207dp" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="257dp"
android:layout_marginBottom="446dp"
android:ems="10"
android:inputType="textPersonName"
android:text="password"
tools:layout_editor_absoluteX="151dp"
tools:layout_editor_absoluteY="273dp" />
<Button
android:id="@+id/button"
android:layout_width="113dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/editText2"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="151dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="101dp"
android:layout_marginEnd="145dp"
android:layout_marginRight="8dp"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText2"
app:layout_constraintVertical_bias="0.126" />
</RelativeLayout>

MainActivity.java

package com.example.relativelayout;

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 {

@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;
});
}
}

OUTPUT:

3. Table Layout
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main"
android:stretchColumns="1">
<TableRow>
<TextView
android:layout_column="1"
android:text="Open..."
android:padding="3dip" />
<TextView
android:text="Ctrl-O"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:layout_column="1"
android:text="Save..."
android:padding="3dip" />
<TextView
android:text="Ctrl-S"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:layout_column="1"
android:text="Save As..."
android:padding="3dip" />
<TextView
android:text="Ctrl-Shift-S"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:text="X"
android:padding="3dip" />
<TextView
android:text="Import..."
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:text="X"
android:padding="3dip" />
<TextView
android:text="Export..."
android:padding="3dip" />
<TextView
android:text="Ctrl-E"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:layout_column="1"
android:text="Quit"
android:padding="3dip" />
</TableRow>
</TableLayout>
MainActivity.java

package com.example.tablelayout;

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 {

@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;
});
}
}
OUTPUT:

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 5 Date: / /

TITLE: Design Login activity and implement control events: Use EditText, Checkbox and
Buttons.
CODE:
Activity_main.xml

<?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"
android:background="#3C415D"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="24*7 Healthcare"
android:textColor="@color/white"
android:textSize="34sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.057" />

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="@color/design_default_color_background"
android:textSize="34sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView7"
app:layout_constraintVertical_bias="0.098" />

<EditText
android:id="@+id/editTextText"
android:layout_width="311dp"
android:layout_height="50dp"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Username"
android:inputType="text"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:textColor="@color/design_default_color_on_primary"
android:textColorHint="@color/design_default_color_on_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView8"
app:layout_constraintVertical_bias="0.13" />

<EditText
android:id="@+id/editTextText2"
android:layout_width="314dp"
android:layout_height="45dp"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Password"
android:inputType="text"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:textColor="@color/design_default_color_on_primary"
android:textColorHint="@color/design_default_color_on_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/editTextText"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="@+id/editTextText"
app:layout_constraintTop_toBottomOf="@+id/editTextText"
app:layout_constraintVertical_bias="0.084" />

<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="I Agree"
android:textColor="#FFF"
app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintEnd_toEndOf="@+id/editTextText2"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/editTextText2"
app:layout_constraintTop_toBottomOf="@+id/editTextText2"
app:layout_constraintVertical_bias="0.621"
tools:ignore="MissingConstraints" />

<Button
android:id="@+id/button2"
android:layout_width="332dp"
android:layout_height="49dp"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.493"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextText2"
app:layout_constraintVertical_bias="0.281" />

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register for New User"
android:textColor="@color/design_default_color_on_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2"
app:layout_constraintVertical_bias="0.321" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
package com.example.loginactivity;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
private View checkBoxAgree;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
checkBoxAgree = findViewById(R.id.checkbox);
checkBoxAgree.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (checkBoxAgree.isPressed()) {
// Handle when the user checks the "I Agree" checkbox
// For example, enable a button or perform an action
} else {
// Handle when the user unchecks the "I Agree" checkbox
// For example, disable a button or perform a different action
}
}
});
}
}
OUTPUT:

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3) (3)

Signature with date:


Experiment No: 6 Date: / /

TITLE: Create a Recycler View and list the details of student using following fields:
1. Name
2. Address
3. Photo (Image)
4. Delete (Button Operation).
CODE:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation="vertical"
tools:context=".MainActivity">

<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recyclelist"/>
</LinearLayout>

Recycler_data_single.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.cardview.widget.CardView
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:id="@+id/btnDelete"/>

<LinearLayout
android:layout_margin="10dp"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="@integer/material_motion_duration_long_1"
android:layout_height="wrap_content">
<TextView
android:textStyle="bold"
android:textColor="@color/black"
android:id="@+id/txtName"
android:text="abcdf"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:textColor="@color/black"
android:id="@+id/txtAddress"
android:text="abcdf"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<ImageView
android:layout_width="50dp"
android:src="@drawable/baseline_delete_24"
android:layout_height="50dp"
android:text="Delete"
android:id="@+id/ImgDelete"
app:tint="@color/Red" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

MainActivity.java
package com.example.mypracticals;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

RecyclerView recyclelist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

recyclelist = (RecyclerView) findViewById(R.id.recyclelist);


recyclelist.setLayoutManager(new GridLayoutManager(MainActivity.this,1));

ArrayList<DataPojo> arrayList = new ArrayList<>();

for (int i = 0; i < 20; i++) {


DataPojo pojo = new DataPojo();
pojo.setName("Name_"+i);
pojo.setAddress("Address_"+i);
pojo.setImage("Image_"+i);
arrayList.add(pojo);
}
RecyclerDataAdapter adapter = new RecyclerDataAdapter(MainActivity.this,arrayList);
recyclelist.setAdapter(adapter);
}
}

RecyclerDataAdapter.java
package com.example.mypracticals;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class RecyclerDataAdapter extends


RecyclerView.Adapter<RecyclerDataAdapter.ViewHolder>{

Context context;
ArrayList<DataPojo> arrayList;

public RecyclerDataAdapter(Context context, ArrayList<DataPojo> arrayList) {


this.context = context;
this.arrayList = arrayList;
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v= LayoutInflater.from(context).inflate(R.layout.recycler_data_single,null,false);
return new ViewHolder(v);
}

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.txtName.setText(arrayList.get(position).getName());
holder.txtAddress.setText(arrayList.get(position).getAddress());

holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, arrayList.get(position).getName()+" Clicked",
Toast.LENGTH_SHORT).show();
}
});
holder.btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, arrayList.get(position).getName()+" Deleted",
Toast.LENGTH_SHORT).show();
arrayList.remove(position);
notifyDataSetChanged();
}
});
holder.ImgDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, arrayList.get(position).getName()+" Deleted",
Toast.LENGTH_SHORT).show();
arrayList.remove(position);
notifyDataSetChanged();
}
});
}

@Override
public int getItemCount() {
return arrayList.size();
}

class ViewHolder extends RecyclerView.ViewHolder {


TextView txtName, txtAddress;
Button btnDelete;
ImageView ImgDelete;
public ViewHolder(@NonNull View itemView) {
super(itemView);
txtName = itemView.findViewById(R.id.txtName);
txtAddress = itemView.findViewById(R.id.txtAddress);
btnDelete = itemView.findViewById(R.id.btnDelete);
ImgDelete = itemView.findViewById(R.id.ImgDelete);
}
}
}
DataPojo.java
package com.example.mypracticals;

public class DataPojo {


private String name;
private String address;
private String image;

public String getName() {


return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
}
OUTPUT:

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 7 Date: / /

TITLE: Write an android application to insert Customer Details (cID, cName, cOrderID) in
SQLite Database in Android.

CODE:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="@+id/cidEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="CID" />
<EditText
android:id="@+id/cnameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="CName" />
<EditText
android:id="@+id/corderidEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="COrderID" />
<Button
android:id="@+id/insertButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Insert Data" />
</LinearLayout>

MainActivity.java
package com.example.practical7;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


EditText cidEditText, cnameEditText, corderidEditText;
Button insertButton;
DatabaseHelper databaseHelper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize UI elements and database helper


cidEditText = findViewById(R.id.cidEditText);
cnameEditText = findViewById(R.id.cnameEditText);
corderidEditText = findViewById(R.id.corderidEditText);
insertButton = findViewById(R.id.insertButton);
databaseHelper = new DatabaseHelper(this);

insertButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Retrieve user input and insert into the database
String cid = cidEditText.getText().toString();
String cname = cnameEditText.getText().toString();
String corderid = corderidEditText.getText().toString();
databaseHelper.insertCustomerDetails(cid, cname, corderid);
}
});
}
}

DatabaseHelper.java
package com.example.practical7;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {


private static final String DATABASE_NAME = "CustomerDB";
private static final String TABLE_NAME = "CustomerDetails";
private static final String COL_CID = "CID";
private static final String COL_CNAME = "CName";
private static final String COL_CORDERID = "COrderID";

public DatabaseHelper(Context context) {


super(context, DATABASE_NAME, null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
String createTable = "CREATE TABLE " + TABLE_NAME + " (" +
COL_CID + " TEXT PRIMARY KEY, " +
COL_CNAME + " TEXT, " +
COL_CORDERID + " TEXT)";
db.execSQL(createTable);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Implement if needed for database upgrades
}

public void insertCustomerDetails(String cid, String cname, String corderid) {


SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COL_CID, cid);
values.put(COL_CNAME, cname);
values.put(COL_CORDERID, corderid);
db.insert(TABLE_NAME, null, values);
db.close();
}
}
OUTPUT:
EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3) (3)

Signature with date:


Experiment No: 8 Date: / /

TITLE: Write an Android application that creates a simple Dialog box with only 1 botton.

CODE:
activity_main.xml

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


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal">
<!-- Add any other views or text here -->
<Button
android:id="@+id/dialogButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am Button"
android:layout_marginTop="80dp" />
</LinearLayout>

MainActivity.java

package com.example.dialogbox;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button dialogButton = findViewById(R.id.dialogButton);
dialogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Create a dialog
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("This is a simple dialog.");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Handle button click
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
});
}
}

OUTPUT:
EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 9 Date: / /

TITLE: Using location service get the current location and display in TextView.
CODE:
activity_main.xml

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


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:id="@+id/locationTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location will be displayed here"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>

MainActivity.java

package com.example.locationservice;

import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
public class MainActivity extends AppCompatActivity {
private TextView locationTextView;
private LocationManager locationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationTextView = findViewById(R.id.locationTextView);
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
// Check location permissions
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
// Request location updates
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, new
LocationListener() {
@Override
public void onLocationChanged(@NonNull Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
locationTextView.setText("Latitude: " + latitude + "\nLongitude: " + longitude);
}
});
} else {
// Request location permissions
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}
}

OUTPUT:
EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 10 Date: / /

TITLE: Display the use of animations.


CODE:
activity_main.xml

<?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"
android:padding="16dp"
android:id="@+id/main"
tools:context=".MainActivity">
<Button
android:id="@+id/animateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Animate"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/animatedView"
android:layout_width="100dp"
android:layout_height="100dp"
tools:srcCompat="@tools:sample/avatars" />
</RelativeLayout>

MainActivity.java

package com.example.animations;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
Button animateButton;
View animatedView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
animateButton = findViewById(R.id.animateButton);
animatedView = findViewById(R.id.animatedView);
animateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.translate_animation);
animatedView.startAnimation(animation);
}
});
}
}

OUTPUT:

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:


Experiment No: 11 Date: / /

TITLE: Create Notification for your application.


CODE:
activity_main.xml

<?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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

package com.example.notification;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
private static final String CHANNEL_ID = "My channel";
private static final Integer NOTIFICATON_ID = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Drawable drawable = ResourcesCompat.getDrawable(getResources(),R.drawable.new_database,
null);
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
Bitmap largeIcon = bitmapDrawable.getBitmap();
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Notification notification;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notification = new Notification.Builder(this)
.setLargeIcon(largeIcon)
.setSmallIcon(R.drawable.new_database)
.setContentText("New Message")
.setSubText("New Message from Krupal")
.setChannelId(CHANNEL_ID)
.build();
notificationManager.createNotificationChannel(new NotificationChannel(CHANNEL_ID,
"New Channel", NotificationManager.IMPORTANCE_HIGH));
}else {
notification = new Notification.Builder(this)
.setLargeIcon(largeIcon)
.setSmallIcon(R.drawable.new_database)
.setContentText("New Message")
.setSubText("New Message from Krupal")
.build();
}
notificationManager.notify(NOTIFICATON_ID, notification);
}
}

OUTPUT:

EVALUATION:

Understanding / Timely
Involvement Total
Problem solving Completion
(4) (10)
(3)
(3)

Signature with date:

You might also like