0% found this document useful (0 votes)
45 views53 pages

Mad Lab Record

Uploaded by

salomia2005
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)
45 views53 pages

Mad Lab Record

Uploaded by

salomia2005
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/ 53

IT3681- MOBILE APPLICATION DEVELOPMENT

LABORATORY RECORD

DEPARTMENT OF

INFORMATION TECHNOLOGY

1
DEPARTMENT OF INFORMATION TECHNOLOGY

IT3681- MOBILE APPLICATION DEVELOPMENT LABORATORY


RECORD

NAME:...................................................................................... ROLL NO: .................................................

SEMESTER: ...............................................................................BRANCH: ..................................................

Certified bonafide record of work done by.........................................................................................

Place: Coimbatore. Date:……………………….

Staff In-Charge Head of the Department

University Register Number: .....................................................................................

Submitted for the University Practical Examination held on.....................................

INTERNAL EXAMINER EXTERNAL EXAMINER

2
INSTITUTION VISION

To be an institution of excellence that provides technical learning in Engineering and Technology to


compete globally and raising the economic standard of the nation.

INSTITUTION MISSION

The stated vision of the institution will be achieved by:


MI1: To impart the sound technical knowledge in diverse engineering disciplines through innovative
pedagogical practices.
MI2: To create conductive learning environment with state-of-art infrastructure, laboratories and
research collaborations.
MI3: To enrich the competences of the students for economic and social developments.
MI4: To empower students with global citizenship education, moral and ethical values in building
sustainable society and nation.

VISION AND MISSION OF THE DEPARTMENT

VISION
To empower technically proficient Information Technology professionals and socially responsible
individuals in an ever-evolving technological landscape .
MISSION
MO1: To import student success through best pedagogical practices and creative use of Information
Technology.
MO2: To create state-of-the-art facilities for elevating technology innovation through research, teaching
and learning.
MO3: To provide sustainable technologies through strategic partnership and community engagement.
MO4: To promote ethical conduct, unwavering integrity, and a strong sense of responsibility within the
realm of Information Technology

3
PROGRAMME EDUCATIONAL OBJECTIVES(PEOs)

1. To provide the students with a strong foundation in the required sciences in order to pursue
studies in Electronics and Communication Engineering.
2. To gain adequate knowledge to become good professional in electronic and communication
engineering associated industries, higher education and research.
3. To develop attitude in lifelong learning, applying and adapting new ideas and technologies as
their field evolves.
4. To prepare students to critically analyze existing literature in an area of specialization and
ethically develop innovative and research-oriented methodologies to solve the problems
identified.
5. To inculcate in the students a professional and ethical attitude and an ability to visualize the
engineering issues in a broader social context.

PROGRAM SPECIFIC OUTCOMES(PSOs)

PSO1: Design, develop and analyze electronic systems through application of relevant electronics,
mathematics and engineering principles.

PSO2: Design, develop and analyze communication systems through application of fundamentals from
communication principles, signal processing, and RF System Design & Electromagnetics.

PSO3: Adapt to emerging electronics and communication technologies and develop innovative
solutions for existing and newer problems.

4
INDEX
Epx.No Date Experiment Name Page Marks Signature
.
No
1. Study and Installation of Flutter/Kotlin multi- 6
platform environment.

2. Develop an application that uses GUI 8


components, Font and Colors.

3. Develop a native calculator application. 12

4. Develop a gaming application that uses 2-D 17


animations and gestures

5. Develop a movie rating application(similar to 21


IMDB)
6. Develop an application to connect to a web 25
service and to retrieve data with HTTP

7. Develop a simple shopping application. 29


8. Design a web server supporting push notifications 33
9. Develop an application by integrating Google 38
maps
10. Mini Project 41
Mini Projects involving Flutter/Kotlin multi-
platform

Total Marks :

Faculty Signature :

5
EX. NO. : 1
Study and Installation of Flutter/Kotlin multi-platform
DATE :
environment.

Aim:

To study and install the development environment required for Flutter and Kotlin
Multiplatform to enable cross-platform mobile and web application development using a
single codebase.

Procedure:

Installing Flutter Development Environment

1. Install Flutter SDK:


o Go to https://flutter.dev.
o Download the stable version of the Flutter SDK for your operating system.
o Extract the contents to a preferred location (e.g., C:\flutter or ~/flutter).
2. Set Environment Variables:
o Add the Flutter SDK's bin folder to your system PATH environment variable.
3. Verify Installation:
o Open a terminal or command prompt and run:

nginx
CopyEdi
t
flutter doctor

o This command checks your environment and displays the status of your setup.
4. Install Android Studio:
o Download from https://developer.android.com/studio.
o Install necessary plugins: Flutter and Dart.
o Configure an Android Virtual Device (AVD) for emulator testing.
5. Install Visual Studio Code (optional):
o Add Flutter and Dart plugins from the Extensions tab for lightweight development.

Installing Kotlin Multiplatform Development Environment

1. Install IntelliJ IDEA or Android Studio:


o Download IntelliJ IDEA Community or Ultimate from
https://www.jetbrains.com/idea/.
6
o Alternatively, use Android Studio which also supports Kotlin Multiplatform.
2. Install Kotlin Plugin (if not bundled):
o Go to Settings → Plugins → Kotlin, then install and restart the IDE.
3. Create a Kotlin Multiplatform Project:
o Select New Project → Kotlin Multiplatform → Mobile Application (KMM).
o Choose targets like Android and iOS.
o Kotlin will create shared modules for business logic and platform-specific modules.
4. Configure Gradle and Dependencies:
o Ensure Gradle is up-to-date and required KMM libraries (like
kotlinx.serialization, ktor, coroutines) are included.
5. Build and Run the Project:
o Run on an Android emulator or iOS simulator.
o Shared code will be compiled and deployed accordingly.

Result :

You will have a working development environment capable of building and running Flutter and
Kotlin Multiplatform applications, supporting cross-platform development for Android, iOS, and
more.

7
EX. NO. : 2
Develop an application that uses GUI components, Font and Colors
DATE :

AIM:
To develop an android application that uses GUI Components, Font and colors.

ALGORITHM:

1. Create a New Android


Project:
● Click New in the
toolbar.
● In the window that appears, open the Android folder, select Android
Application Project, and click next.
● Provide the application name and the project name and then
finally give the desired package name.
● Choose a launcher icon for your application and then select Blank
Activity and then click Next
● Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target, an SD
card size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android
Virtual Device Manager and click Start.
3. Design the graphical layout with a text view and two command buttons.
4. Run the application.
5. On pressing the change color button, color of the text gets changed.
6. On pressing the change font size button, the size of the font gets altered.
7. Close the Android project.

8
PROGRAM CODE
MainActivity.java
package com.example.p1;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


int ch = 1;
float font = 30;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize TextView and Buttons
final TextView t = findViewById(R.id.textView);
Button b1 = findViewById(R.id.button1);
Button b2 = findViewById(R.id.button2);
// Set the text size change behavior
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
t.setTextSize(font); // Set current font size
font = font + 5; // Increase font size by 5
if (font == 50) { // Reset font size back to 30 after 50
font = 30;

}
}
});

// Set text color change behavior


b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { switch (ch) {

case 1:
t.setTextColor(Color.RED);

break;

9
case 2:
t.setTextColor(Color.GREEN);
break;

case 3:
t.setTextColor(Color.BLUE);
break;

case 4:
t.setTextColor(Color.CYAN);
break;

case 5:
t.setTextColor(Color.YELLOW);
break;

case 6:

t.setTextColor(Color.MAGENTA);
break;
}
ch++; // Increment color case
if (ch == 7) { // Reset color counter to 1 ch = 1;
}
}
});
}

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="vertical"
android:gravity="center"
android:padding="16dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World"
android:textSize="30sp"
android:layout_marginBottom="20dp" />

10
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Increase Text Size"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Text Color" />

</LinearLayout>

Output :

RESULT:
Thus, the program for android application GUI Components, Font and colors was executed
successfully.

11
EX. NO. : 3
Develop a native calculator application.
DATE :

Aim:

To design and implement a basic native calculator application.

Algorithm :

1. Initialize states (input, result, operator, isNewInput)


2. Display current input
3. On digit press, update input
4. On operator press, store result and operator
5. On = press, perform calculation and update result
6. On special key (C, +/-, %), modify input accordingly
7. Update UI with changes.

Program code :

import React, { useState } from "react";


import {
View,
Text,
TouchableOpacity,
StyleSheet,
StatusBar,
} from "react-native";

const App = () => {


const [input, setInput] = useState("0");
const [result, setResult] = useState(null);
const [operator, setOperator] = useState(null);
const [isNewInput, setIsNewInput] = useState(true);

const handleDigitPress = (digit) => {


if (isNewInput) {
setInput(digit === "." ? "0." : digit);
setIsNewInput(false);
} else if (digit === "." && input.includes(".")) {
return;
} else {
setInput(input + digit);

12
}
};

// Function to handle operator press


const handleOperatorPress = (op) => {
if (operator && !isNewInput) {
calculate();
} else {
setResult(parseFloat(input));
}
setOperator(op);
setIsNewInput(true);
};

// Function to calculate the result


const calculate = () => {
if (operator && result !== null) {
let current = parseFloat(input);
let newResult = result;

switch (operator) {
case "+":
newResult += current;
break;
case "-":
newResult -= current;
break;
case "x":
newResult *= current;
break;
case "/":
newResult /= current;
break;
default:
return;
}

setInput(newResult.toString());
setResult(newResult);
setOperator(null);
setIsNewInput(true);
}
};

13
// Function to handle special buttons
const handleSpecialPress = (type) => {
switch (type) {
case "C":
setInput("0");
setResult(null);
setOperator(null);
setIsNewInput(true);
break;
case "+/-":
setInput((parseFloat(input) * -1).toString());
break;
case "%":
setInput((parseFloat(input) / 100).toString());
break;

default:
break;
}
};

return (
<View style={styles.container}>
<StatusBar />
<View style={styles.displayContainer}>
<Text style={styles.displayText}>{input}</Text>
</View>
<View style={styles.buttonContainer}>
{["C", "+/-", "%", "/"].map((op) => (
<Button key={op} label={op} onPress={() => handleSpecialPress(op)} />
))}
{["7", "8", "9", "x"].map((item) => (
<Button
key={item}
label={item}
onPress={() =>
item === "x" ? handleOperatorPress(item) : handleDigitPress(item)
}
/>
))}
{["4", "5", "6", "-"].map((item) => (
<Button
key={item}
label={item}
14
onPress={() =>
item === "-" ? handleOperatorPress(item) : handleDigitPress(item)
}
/>
))}
{["1", "2", "3", "+"].map((item) => (
<Button
key={item}
label={item}
onPress={() =>
item === "+" ? handleOperatorPress(item) : handleDigitPress(item)
}
/>
))}
{["0", ".", "="].map((item) => (
<Button
key={item}
label={item}
onPress={() =>
item === "=" ? calculate() : handleDigitPress(item)
}
/>
))}
</View>
</View>
);
};

// Reusable Button Component


const Button = ({ label, onPress }) => (
<TouchableOpacity style={styles.button} onPress={onPress}>
<Text style={styles.buttonText}>{label}</Text>
</TouchableOpacity>
);

});

export default App;

15
Output :

RESULT:
Thus, the program for developing an application for native calculator was executed
successfully.

16
EX. NO. : 4
Develop a gaming application that uses 2-D animations and gestures
DATE :

AIM:
To develop an android application that draws basic graphical primitives on the screen.

ALGORITHM:

1. Create a New Android Project:


● Click New in the toolbar.
● In the window that appears, open the Android folder,
select Android Application Project, and click next.
● Provide the application name and the project name and then
finally give the desired package name.
● Choose a launcher icon for your application and then select Blank
Activity and then click Next
● Provide the desired Activity name for your project and then click
Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target,
an SD card size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android
Virtual Device Manager and click Start.
3. Design the layout by adding a ImageView button.
4. Run the application.
5. Draw straight line by moving the mouse over the screen.
6. Close the Android project.

17
Program Code :
MainActivity.java:
package com.example.p3;
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); // Use all lowercase: activity_main

// Create a Bitmap
Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
// Create a Canvas using the Bitmap Canvas canvas = new Canvas(bg);

// Create a Paint object Paint paint = new Paint();


paint.setColor(Color.BLUE); paint.setTextSize(50);

// Draw shapes
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);

// Get the ImageView and set the Bitmap as its background

ImageView imageView = findViewById(R.id.imageView); imageView.setBackground(new


BitmapDrawable(getResources(), bg)); // modern
18
method
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView android:id="@+id/imageView"
android:layout_width="match_parent"

android:layout_height="match_parent"
android:contentDescription="Canvas drawing area"
android:background="#FFFFFF" />

</FrameLayout>

19
Output:

RESULT:
Thus, the program for developing an application for native calculator was executed
successfully.

20
EX. NO: 5 Develop a movie rating application(similar to IMDB).
DATE :

Aim :

To develop a movie rating application that allows users to browse movies, view details, submit star
ratings and reviews, and view aggregated feedback, similar to IMDb.

Algorithm :

1. Design data models for movies and reviews.


2. Set up a backend or local database to store movie and review data.
3. Build a user interface with screens for movie listing and details.
4. Fetch and display movies in a list using an API or database.
5. Display movie details with description, ratings, and reviews.
6. Implement a rating dialog for users to rate and comment.
7. Submit ratings and reviews to the backend or local storage.
8. Calculate and update average ratings after each review.
9. Enable user authentication for personalized review tracking (optional).
10. Enhance UI/UX with search, filters, and animations.

Program Code :

package com.hosseiniseyro.sample

import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.FragmentActivity
import com.hosseiniseyro.apprating.AppRatingDialog
import com.hosseiniseyro.apprating.listener.RatingDialogListener
import kotlinx.android.synthetic.main.activity_samples.*

class SamplesActivity : FragmentActivity(), RatingDialogListener {

override fun onCreate(savedInstanceState: Bundle?) {


super.onCreate(savedInstanceState)
setContentView(R.layout.activity_samples)

showDialogButton_1.setOnClickListener { showRatingDialog_example1() }
showDialogButton_2.setOnClickListener { showRatingDialog_example2() }
showDialogButton_3.setOnClickListener { showRatingDialog_example3() }

21
showDialogButton_4.setOnClickListener { showRatingDialog_example4() }

buildRatingDialog().monitor()
buildRatingDialog().showRateDialogIfMeetsConditions()
}

private fun buildRatingDialog(): AppRatingDialog {


return AppRatingDialog.Builder()
.setPositiveButtonText("Submit")
.setNegativeButtonText("Cancel")
.setNeutralButtonText("Later")
.setNoteDescriptions(listOf("Very Bad", "Not good", "Quite ok", "Very Good", "Excellent !!!"))
.setDefaultRating(2)
.setThreshold(4)
.setAfterInstallDay(0)
.setNumberOfLaunches(3)
.setRemindInterval(2)
.setTitle("Rate this application")
.setDescription("Please select some stars and give your feedback")
.setStarColor(R.color.starColo
.setHintTextColor(R.color.hintTextColor)
.setCancelable(false)
.setCanceledOnTouchOutside(false)
.create(this@SamplesActivity)
}

private fun showRatingDialog_example1() {


AppRatingDialog.Builder()
.setPositiveButtonText("Submit")
.setNegativeButtonText("Cancel")
.setNeutralButtonText("Later")
.setNoteDescriptions(
listOf(
"Very Bad",
"Not good",
"Quite ok",
"Very Good",
"Excellent !!!"
)
)
.setDefaultRating(2)
.setThreshold(4)
.setTitle("Rate this application")
.setDescription("Please select some stars and give your feedback")
.setStarColor(R.color.starColor)
.setDialogBackgroundColor(R.color.rateAppDialogBackgroundColor)
.setWindowAnimation(R.style.MyDialogSlideHorizontalAnimation)
.setHint("Please write your comment here ...")
22
.setHintTextColor(R.color.hintTextColor)
.setCancelable(false)
.setCanceledOnTouchOutside(false)
.create(this@SamplesActivity)
.show()
}

private fun showRatingDialog_example2() {


AppRatingDialog.Builder()
.setPositiveButtonText("Send feedback")
.setNumberOfStars(6)
.setDefaultRating(0)
.setTitle("Rate this application")
.setDefaultComment(R.string.defaultComment)
.setHint("Please write your comment here ...")
.setHintTextColor(R.color.hintTextColor)
.create(this@SamplesActivity)
.show()
}

private fun showRatingDialog_example3() {


AppRatingDialog.Builder()
.setPositiveButtonText(R.string.send_review)
.setNegativeButtonText(R.string.cancel)
.setNeutralButtonText(R.string.later)
.setNoteDescriptions(listOf("Very Bad", "Not good", "Quite ok", "Very Good", "Excellent !!!"))
.setNumberOfStars(5)
.setDefaultRating(3)
.setHintTextColor(R.color.hintTextColor2)
.setWindowAnimation(R.style.MyDialogSlideVerticalAnimation)
.create(this@SamplesActivity)
.show()
}

private fun showRatingDialog_example4() {


AppRatingDialog.Builder()
.setPositiveButtonText("Send feedback")
.setNumberOfStars(6)
.setDefaultRating(4)
.setTitle("Rate this application")
.setTitleTextColor(R.color.titleTextColor2)
.setCommentInputEnabled(false)
.setWindowAnimation(R.style.MyDialogFadeAnimation)
.setHint("Please write your comment here ...")
.setHintTextColor(R.color.hintTextColor2)
.setCommentTextColor(R.color.commentTextColor2)
.setCommentBackgroundColor(R.color.commentBackgroundColor2)
.create(this@SamplesActivity)
23
.show()
}

override fun onPositiveButtonClickedWithComment(rate: Int, comment: String) {


Toast.makeText(this@SamplesActivity, "Rate : $rate\nComment : $comment",
Toast.LENGTH_LONG)
.show()
}
override fun onPositiveButtonClickedWithoutComment(rate: Int) {
Toast.makeText(this@SamplesActivity, "Rate : $rate\n go to market",
Toast.LENGTH_LONG).show()
}
override fun onNegativeButtonClicked() {
Toast.makeText(this@SamplesActivity, "Negative button clicked", Toast.LENGTH_LONG).show()
}
override fun onNeutralButtonClicked() {
Toast.makeText(this@SamplesActivity, "Neutral button clicked", Toast.LENGTH_LONG).show()
}
}

Output :

RESULT:

Thus, the program for developing a movie rating application was executed successfully.

24
EX. NO. :6
Develop an application to connect to a web service and to retrieve
DATE : data with HTTP

AIM:
To develop an android application that implements multithreading.

ALGORITHM:

1. Create a New Android


Project:
● Click New in the
toolbar.
● In the window that appears, open the Android folder, select Android
Application Project, and click next.
● Provide the application name and the project name and then finally
give the desired package name.
● Choose a launcher icon for your application and then select Blank Activity
and then click Next
● Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target, an SD
card size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the graphical layout.
4. Run the application.
5. The requested data is retrieved from the database named myFriendsDb.
6. Close the Android project.

25
Program Code :
MainActivity.Java
package com.example.admin.multithreading;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivityextends AppCompatActivity


{
ImageViewimg; Button bt1,bt2; @Override protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

bt1 = (Button)findViewById(R.id.button);
bt2= (Button) findViewById(R.id.button2);
img= (ImageView)findViewById(R.id.imageView);

bt1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
new Thread(new Runnable()
{
@Override public void run()
{
img.post(new Runnable()
{

public void run() @Override


{
img.setImageResource(R.drawable.india1);
}
});
}
}).start();
}
});
bt2.setOnClickListener(new View.OnClickListener()
{
@Override
26
public void onClick(View v)
{
new Thread(new Runnable()
{
@Override public void run()

{
img.post(new Runnable()
{

public void run() @Override


{
img.setImageResource(R.drawable.india2);
}
});
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView android:id="@+id/imageView"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="50dp"
android:layout_gravity="center" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load Image 1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load image 2" />

</LinearLayout>

27
Output :

RESULT:
Thus, the program for android application that makes use of multithreading was executed
successfully.

28
EX. NO. :7 Develop a simple shopping application.
DATE :

AIM:
To develop an android application that creates an alert upon receiving a message.

ALGORITHM:
1. Create a New Android
Project:
● Click New in the toolbar.
● In the window that appears, open the Android folder, select Android
Application Project, and click next.
● Provide the application name and the project name and then finally give
the desired package name.
● Choose a launcher icon for your application and then select Blank Activity and
then click Next
● Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target, an SD card
size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the layout by adding a text box and a command button.
4. Run the application.
5. If the entered E-mail doesn’t match the given E-mail id, then an alert will be
displayed.
6. If the entered E-mail id matches with the provided mail-id then login is successful.
Close the Android project

29
Program Code :
MainActivity.java
package com.pa.Alert;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity { private Button BTN;
private EditText email;
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BTN = (Button) findViewById(R.id.btn);
email = (EditText) findViewById(R.id.emailInput);
BTN.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String val = email.getText().toString();
if (val == null || val.length() <= 0) {
Toast.makeText(getApplicationContext(),
"Please Enter the email", Toast.LENGTH_LONG).show();
} else if (val.equals("enpboss@gmail.com")) {
Intent intent = new Intent(getApplicationContext(), SecondActivity.class); startActivity(intent);
Toast.makeText(getApplicationContext(),
"Login Success",
Toast.LENGTH_LONG).show();
} else
{
Toast.makeText(getApplicationContext(),
"Please Enter valid email",
Toast.LENGTH_LONG)
.show();
}
}
});
}

30
}

SecondActivity.java
package com.pa.Alert;
import android.app.Activity;
import android.os.Bundle;
public class SecondActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub super.onCreate(savedInstanceState);
setContentView(R.layout.second_activity);
}
}
AndroidMainfest.Xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admin.myapplication">
<application android:allowBackup="true"
android:icon="@mipmap/ic_launcher "
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>

<action android:name="
android.intent.action.MAIN" />
<category android:name="
android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

31
Output :

RESULT:
Thus, the program for android application that creates an alert upon receiving a message
was executed successfully.

32
EX. NO. : 8
Design a web server supporting push notifications
DATE :

AIM:
To develop an android application that makes use of RSS (Rich Site Summary) Feed.

ALGORITHM:

1. Create a New Android


Project:
● Click New in the
toolbar.
● In the window that appears, open the Android folder, select Android
Application Project, and click next.
● Provide the application name and the project name and then finally
give the desired package name.
● Choose a launcher icon for your application and then select Blank Activity
and then click Next
● Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target, an SD
card size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the graphical layout using buttons, text and ImageView.
4. Run the application.
5. Fetch the details from the URL.
6. Display the output by clicking the result button.
Close the Android project

33
Program Code :
MainActivity.java:
package com.example.p2;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private EditText eTo;
private EditText eSubject;
private EditText eMsg;
private Button btn;
@Override protected void onCreate(Bundle savedInstanceState)
{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

eTo = (EditText)findViewById(R.id.txtTo);
eSubject = (EditText)findViewById(R.id.txtSub);
eMsg = (EditText)findViewById(R.id.txtMsg);
btn = (Button)findViewById(R.id.btnSend);
btn.setOnClickListener(new View.OnClickListener()
{
@Override public void onClick(View v)
{
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL,
new String[]{eTo.getText().toString()});

it.putExtra(Intent.EXTRA_SUBJECT,eSubject.getText().toString());
it.putExtra(Intent.EXTRA_TEXT,eMsg.getText()); it.setType("message/rfc822");

startActivity(Intent.createChooser(it,"Choose Mail
App" ));

}
}
);
}

Activity_main.xml:

34
<?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:paddingLeft="20dp"
android:paddingRight="20dp"
android:orientation="vertical" >
<EditText android:id="@+id/txtTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="To"/>
<EditText android:id="@+id/txtSub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Subject"/>
<EditText android:id="@+id/txtMsg"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="Message"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content
android:layout_gravity="right"
android:text=" Compose An Email"
android:id="@+id/btnSend"/>
</LinearLayout>

Andriodmanifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

package="com.example.p2">
<!-- Permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<!-- For backward compatibility -->


<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

35
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />

<!-- Application tag properly closed now -->


<application android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.P2"
android:requestLegacyExternalStorage="true" tools:targetApi="31">
<!-- Main activity declaration -->
<activity android:name="com.example.p2.MainActivity"
android:exported="true">
<!-- Intent Filter for Main Activity (App Launch) -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<!-- Intent Filter for Send Email Action -->


<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="message/rfc822" />
</intent-filter>

</activity>
</application>

36
Output :

RESULT:

Thus, the program for android application that makes use of RSS Feed was executed
successfully.

37
EX. NO. : 9
Develop an application by integrating Google maps
DATE :

AIM:
To develop an android application that send an email.
ALGORITHM:

1. Create a New Android


Project:
● In the window that appears, open the Android folder, select Android
Application Project, and click next.
● Provide the application name and the project name and then finally give
the desired package name.
● Choose a launcher icon for your application and then select Blank Activity and
then click Next
● Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target, an SD card
size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the graphical layout.
4. Run the application.
5. When the application starts alarm sound will be invoked.
6. Stop alarm button is clicked to stop the alarm.
7. Close the Android project.

Program Code:
MainActivity.java:
package com.example.p2;
import android.Manifest; import android.content.Context;
import android.content.pm.PackageManager; import android.location.Location;
import android.location.LocationListener; import android.location.LocationManager; import
android.os.Build;
import android.os.Bundle;
import androidx.annotation.RequiresApi; import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
38
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements LocationListener {
protected LocationManager locationManager; protected LocationListener locationListener;
TextView txtLat;
@RequiresApi(api = Build.VERSION_CODES.M) @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
@Override
public void onLocationChanged(Location location) {
// Display the location on the TextView
txtLat.setText("Latitude: " + location.getLatitude() + ", Longitude: " + location.getLongitude());
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) { Log.d("Latitude", "Status
changed: " + provider + ", Status: " + status);
}
// Callback when the provider is enabled @Override
public void onProviderEnabled(String provider) { Log.d("Latitude", provider + " enabled");
}

// Callback when the provider is disabled @Override


public void onProviderDisabled(String provider) { Log.d("Latitude", provider + " disabled");
}
// Handle runtime permission result @Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Permission granted, request location updates if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) ==
PackageManager.PERMISSION_GRANTED) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
} else {
// Permission denied, you can handle the case where the user denies permission
Log.d("Latitude", "Permission denied.");
}
}
}
39
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="com.example.p2.MainActivity">
<!-- First TextView for message -->
<TextView android:id="@+id/textView2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Your location is"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="50dp" />
<!-- Second TextView for showing the location -->
<TextView android:id="@+id/loading"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Loading..." app:layout_constraintTop_toBottomOf="@id/textView2"
app:layout_constraintLeft_toLeftOf="parent" android:layout_marginTop="20dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</manifest>

Output :

RESULT:
Thus, the program for android application to send an email was executed successfully.
40
EX. NO. :10 Mini Project
Mini Projects involving Flutter/Kotlin multi-platform
DATE :

AIM:
To develop a calculator android application.

ALGORITHM:

1. Create a New Android Project:


● Click New in the toolbar.
● In the window that appears, open the Android folder, select Android
Application Project, and click next.
● Provide the application name and the project name and then finally
give the desired package name.
● Choose a launcher icon for your application and then select Blank
Activity and then click Next
● Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
● click Android Virtual Device Manager from the toolbar.
● In the Android Virtual Device Manager panel, click New.
● Fill in the details for the AVD. Give it a name, a platform target, an SD card
size, and a skin (HVGA is default).
● Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Run the application.
4. Provide any two input numbers.
5. Choose any arithmetic operations of your choice and the output gets
displayed on the display screen of the calculator application.
6. Close the Android project.

Program Code:

MainActivity.java
package com.example.calculator_two;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

41
import android.widget.EditText;

public class MainActivity extends Activity implements OnClickListener {

private Button nine, eig, sev, six, fiv, four, thr, two, one, zero, dot,

plus, mins, div, mul, eq, cl;

private EditText et;

private String s = "0";

private int result = 0;

private char lO = ' ';

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub super.onCreate(savedInstanceState); s

etContentView(R.layout.activity_main);

nine = (Button) findViewById(R.id.b9);

eig = (Button) findViewById(R.id.b8);

sev = (Button) findViewById(R.id.b7);

six = (Button) findViewById(R.id.b6);

fiv = (Button) findViewById(R.id.b5);

four = (Button) findViewById(R.id.b4);

thr = (Button) findViewById(R.id.b3);

two = (Button) findViewById(R.id.b2);

one = (Button) findViewById(R.id.b1);

zero = (Button) findViewById(R.id.b0);

dot = (Button) findViewById(R.id.bd);


42
plus = (Button) findViewById(R.id.bpl);

mins = (Button) findViewById(R.id.bmin);

div = (Button) findViewById(R.id.bdiv);

mul = (Button) findViewById(R.id.bmul);

eq = (Button) findViewById(R.id.beq);

cl = (Button) findViewById(R.id.bcl);

et = (EditText) findViewById(R.id.tv);

zero.setOnClickListener(this);

nine.setOnClickListener(this);

eig.setOnClickListener(this);

sev.setOnClickListener(this);

six.setOnClickListener(this);

fiv.setOnClickListener(this);

four.setOnClickListener(this);

thr.setOnClickListener(this);

two.setOnClickListener(this);

one.setOnClickListener(this);

dot.setOnClickListener(this);

plus.setOnClickListener(this);

mins.setOnClickListener(this);

div.setOnClickListener(this);

mul.setOnClickListener(this);

eq.setOnClickListener(this);
43
cl.setOnClickListener(this);

et.setOnClickListener(this);

public void onClick(View v) { switch (v.getId()) { case R.id.b0:

case R.id.b1:

case R.id.b2:

case R.id.b3:

case R.id.b4:

case R.id.b5:

case R.id.b6:

case R.id.b7:

case R.id.b8:

case R.id.b9:

String inDigit = ((Button) v).getText().toString();

if (s.equals("0")) { s = inDigit;

} else {

s += inDigit;

et.setText(s);

if (lO == '=') { result = 0;

lO = ' ';

break
44
; case R.id.bpl:

compute();

lO = '+';

break;

case

R.id.bmin:

compute();

lO = '-';

break;

case

R.id.bdiv:

compute();

lO = '/';

break;

case

R.id.bmul:

compute();

lO = '*';

break;

case R.id.beq:

compute();

lO = '=';
45
break;

case

R.id.bcl:

result = 0;

s = "0";

lO = ' ';

et.setText("0");

break;

private void compute() {

int inNum = Integer.parseInt(s);

s = "0";

if (lO == ' ') {

result = inNum;

} else if (lO == '+') { result += inNum;

} else if (lO == '-') { result -= inNum;

} else if (lO == '*') { result *= inNum;

} else if (lO == '/') { result /= inNum;

} else if (lO == '=') {

// Keep the result for the next operation

et.setText(String.valueOf(result));
46
}

activity_main.xml

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

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android "
android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

<EditText android:id="@+id/tv"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="enter no. here"

android:textSize="30dp" />

<LinearLayout android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginTop="100dp"

android:orientation="horizontal"

android:weightSum="4">

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

47
android:layout_weight="1"

android:text="6"

android:textColor="#ff0000" />

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="5"

android:textColor="#ff0000" />

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="4"

android:textColor="#ff0000" />

<Button

android:id="@+id/bmin"

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="-"

android:textColor="#ff0000" />

</LinearLayout>
48
<LinearLayout android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:weightSum="4">

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="3"

android:textColor="#ff0000" />

<Button

android:id="@+id/b2"

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="2"

android:textColor="#ff0000" />

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

android:layout_width="match_parent"

android:layout_height="wrap_content " a

ndroid:layout_weight="1" android:text="1"

android:textColor="#ff0000" />

<Button
49
android:id="@+id/bmul"

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="*"

android:textColor="#ff0000" />

</LinearLayout>

<LinearLayout android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:weightSum="5">

<Button

android:id="@+id/bd"

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="." android:textColor="#ff0000" />

<Button

android:id="@+id/b0"

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="0"
50
android:textColor="#ff0000" />

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="Clr"

android:textColor="#ff0000" />

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="="

android:textColor="#ff0000" />

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

android:layout_width="match_parent"

android:layout_height="wrap_content "

android:layout_weight="1"

android:text="/"

android:textColor="#ff0000" />

</LinearLayout

51
Output :

RESULT:
Thus, the program for android based calculator application was executed successfully.

52
53

You might also like