0% found this document useful (0 votes)
24 views59 pages

IT3681MOBILE APPLICATIONS DEVELOPMENT LABORATORY Manual

The document outlines the lesson plan for the Mobile Applications Development Laboratory course at Jayaraj Annapackiam C S I College of Engineering for the academic year 2024-2025. It includes the course objectives, a list of experiments, and the expected outcomes for students, emphasizing the use of Flutter/Kotlin for cross-platform mobile app development. Additionally, it details the installation process for the Flutter SDK on both Windows and MacOS systems and provides a sample project for creating a simple Android application.

Uploaded by

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

IT3681MOBILE APPLICATIONS DEVELOPMENT LABORATORY Manual

The document outlines the lesson plan for the Mobile Applications Development Laboratory course at Jayaraj Annapackiam C S I College of Engineering for the academic year 2024-2025. It includes the course objectives, a list of experiments, and the expected outcomes for students, emphasizing the use of Flutter/Kotlin for cross-platform mobile app development. Additionally, it details the installation process for the Flutter SDK on both Windows and MacOS systems and provides a sample project for creating a simple Android application.

Uploaded by

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

Jayaraj Annapackiam C S I College Of Engineering

Margoschis Nagar, Nazareth – 628 617


Department of Information Technology

Academic Year :2024-2025(EVEN SEM)


Semester :VI
Staff Name :G.Princely Linda Mary
Designation :Assistant professor
Department :IT
Regulation : 2021

Lesson Plan

IT3681 / Mobile Applications Development


Laboratory

PREPARED BY VERIFIED BY APPROVED BY


G. Princely Linda
Mary
JAYARAJ ANNAPACKIAM C.S.I COLLEGE OF ENGINEERING
(Approved by AICTE, New Delhi and Affiliated to Anna University)
MARGOSCHIS NAGAR, NAZARETH – 628 617

DEPARTMENT OF INFORMATION TECHNOLOGY (R 2021)

VISION
To produce competent IT professionals offering quality technical education to meet industrial and societal
needs.
MISSION
1. To provide academic excellence and inculcate the spirit of professionalism.
2. To empower students with research and entrepreneurial capabilities for addressing societal problems.
3. To establish collaboration with industries for technology transfer.
4. To promote continuous learning and nurture creativity skills with strong ethical values.
PROGRAM EDUCATIONAL OBJECTIVES (PEOs)
1. Demonstrate technical competence with analytical and critical thinking to understand and meet the diversified
requirements of industry, academia and research.
2. Exhibit technical leadership, team skills and entrepreneurship skills to provide business solutions to real world
problems.
3. Work in multi-disciplinary industries with social and environmental responsibility, work ethics and adaptability
to address complex engineering and social problems.
4. Pursue lifelong learning, use cutting edge technologies and involve in applied research to design optimal
solutions.

PROGRAM OUTCOMES (POs)


ENGINEERING GRADUATES WILL BE ABLE TO:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an
engineering specialization to the solution of complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems
reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health and safety,
and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods including
design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an understanding of
the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and
environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering
practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in
multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering community and
with society at large, such as, being able to comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management
principles and apply these to one‘s own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-
long learning in the broadest context of technological change.

PROGRAM SPECIFIC OBJECTIVES (PSOs)


1. Have proficiency in programming skills to design, develop and apply appropriate techniques, to solve complex
engineering problems.
2. Have knowledge to build, automate and manage business solutions using cutting edge technologies.
3. Have excitement towards research in applied computer technologies.

.
IT3681 MOBILE APPLICATIONS DEVELOPMENT LABORATORY
COURSE OBJECTIVES:
The objective of this course is to enable the students to
● Use Flutter/Kotlin multi-platform environment for building
cross platform mobile applications.
● Demonstrate the knowledge of different programming techniques
and patterns for mobile application development.
● Identify the components and structure of mobile application development frameworks.
● Understand the capabilities and limitations of different platforms.
● Design and develop real-time mobile applications.

LIST OF EXPERIMENTS:
● Study and installation of Flutter/Kotlin multi-platform environment
● Develop an application that uses Widgets, GUI components, Fonts, and Colors.
● Develop a native calculator application.
● Develop a gaming application that uses 2-D animations and gestures.
● Develop a movie rating application (similar to IMDB)
● Develop an application to connect to a web service and to retrieve data with HTTP.
● Develop a simple shopping application.
● Design a web server supporting push notifications.
● Develop an application by integrating Google maps
● Mini Projects involving Flutter/Kotlin multi-platform

TEXTBOOKS:
1. Simone Alessandria, Flutter Projects: A practical project-based guide to
building real-world cross-platform mobile applications and games, Packt
publishing.
2. Carmine Zaccagnino, Programming Flutter: Native, Cross-Platform
Apps the Easy Way (The Pragmatic Programmers), Packt publishing.
REFERENCES
1. Gergely Orosz, Building Mobile Applications at Scale:39 Engineering Challenges
2. Souvik Biswas & Codemagic, Flutter Libraries we love
3. ED Freitas, Daniel Jebaraj, Flutter Succinctly
4. Antonio Leiva, Kotlin for Android Developers Learn Kotlin the easy way while
developing an Android Applications

COURSE OUTCOMES:
On successful completion of this course, the student should be able to
CO1:Design and build simple mobile applications supporting multiple
platforms.
CO2:Apply various programming techniques and patterns to build
mobile applications.
CO3:Build real-time mobile applications for society/environment
CO4:Build gaming and multimedia based mobile applications
CO5:Build AI based mobile applications for society/environment following ethical practices
TABLE OF CONTENTS

Ex. Teaching
No.of
No Topics to be covered Method
Periods
. Followed
1 Study and installation of Flutter/Kotlin multi-platform environment 5 GTM

Develop an application that uses Widgets, GUI components, Fonts, 5


2 and Colors. GTM

Develop a native calculator application. 5


3 GTM

4 Develop a gaming application that uses 2-D animations and gestures 6 GTM
Develop a movie rating application (similar to IMDB) 6
5 GTM

Develop an application to connect to a web service and to retrieve data 6


6 GTM
with HTTP
Develop a simple shopping application. 6
7 GTM

Develop an application by integrating Google maps 6


8 GTM
Ex.No:1 Study and installation of Flutter/Kotlin multi-
platform environment

Introduction

In general, developing a mobile application is a complex and challenging task. There are many frameworks
available to develop a mobile application. Android provides a native framework based on Java language and iOS
provides a native framework based on Objective-C / Swift language.

However, to develop an application supporting both the OSs, we need to code in two different languages using
two different frameworks. To help overcome this complexity, there exists mobile frameworks supporting both
OS. These frameworks range from simple HTML based hybrid mobile application framework (which uses
HTML for User Interface and JavaScript for application logic) to complex language specific framework (which
do the heavy lifting of converting code to native code). Irrespective of their simplicity or complexity, these
frameworks always have many disadvantages, one of the main drawback being their slow performance.

In this scenario, Flutter – a simple and high performance framework based on Dart language, provides high
performance by rendering the UI directly in the operating system’s canvas rather than through native framework.

Flutter also offers many ready to use widgets (UI) to create a modern application. These widgets are optimized
for mobile environment and designing the application using widgets is as simple as designing HTML.

To be specific, Flutter application is itself a widget. Flutter widgets also supports animations and gestures. The
application logic is based on reactive programming. Widget may optionally have a state. By changing the state of
the widget, Flutter will automatically (reactive programming) compare the widget’s state (old and new) and
render the widget with only the necessary changes instead of re-rendering the whole widget.

We shall discuss the complete architecture in the coming chapters.

Features of Flutter

Flutter framework offers the following features to developers −

● Modern and reactive framework.


● Uses Dart programming language and it is very easy to learn.
● Fast development.
● Beautiful and fluid user interfaces.
● Huge widget catalog.
● Runs same UI for multiple platforms.
● High performance application.

Installation in Windows

In this section, let us see how to install Flutter SDK and its requirement in a windows system.

Step 1 − Go to URL, https://flutter.dev/docs/get-started/install/windows and download the latest Flutter SDK. As


of April 2019, the version is 1.2.1 and the file is flutter_windows_v1.2.1-stable.zip.

Step 2 − Unzip the zip archive in a folder, say C:\flutter\

Step 3 − Update the system path to include flutter bin directory.


Step 4 − Flutter provides a tool, flutter doctor to check that all the requirement of flutter development is met.
flutter doctor

Step 5 − Running the above command will analyze the system and show its report as shown below −

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows
[Version 10.0.17134.706], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK
version 28.0.3)
[√] Android Studio (version 3.2)
[√] VS Code, 64-bit edition (version
1.29.1) [!] Connected device
! No devices available
! Doctor found issues in 1 category.

The report says that all development tools are available but the device is not connected. We can fix
this by connecting an android device through USB or starting an android emulator.

Step 6 − Install the latest Android SDK, if reported by flutter doctor

Step 7 − Install the latest Android Studio, if reported by flutter doctor

Step 8 − Start an android emulator or connect a real android device to the system.

Step 9 − Install Flutter and Dart plugin for Android Studio. It provides startup template to create new Flutter
application, an option to run and debug Flutter application in the Android studio itself, etc.,

● Open Android Studio.


● Click File → Settings → Plugins.
● Select the Flutter plugin and click Install.
● Click Yes when prompted to install the Dart plugin.
● Restart Android studio.

Installation in MacOS

To install Flutter on MacOS, you will have to follow the following steps −

Step 1 − Go to URL, https://flutter.dev/docs/get-started/install/macos and download latest Flutter SDK. As of


April 2019, the version is 1.2.1 and the file is flutter_macos_v1.2.1- stable.zip.

Step 2 − Unzip the zip archive in a folder, say /path/to/flutter

Step 3 − Update the system path to include flutter bin directory (in ~/.bashrc file).

> export PATH = "$PATH:/path/to/flutter/bin"

Step 4 − Enable the updated path in the current session using below command and then verify it as well.

source ~/.bashrc
source $HOME/.bash_profile echo $PATH
Flutter provides a tool, flutter doctor to check that all the requirement of flutter development is met. It is
similar to the Windows counterpart.

Step 5 − Install latest XCode, if reported by flutter doctor

Step 6 − Install latest Android SDK, if reported by flutter doctor

Step 7 − Install latest Android Studio, if reported by flutter doctor

Step 8 − Start an android emulator or connect a real android device to the system to develop android application.

Step 9 − Open iOS simulator or connect a real iPhone device to the system to develop iOS application.

Step 10 − Install Flutter and Dart plugin for Android Studio. It provides the startup template to create a new
Flutter application, option to run and debug Flutter application in the Android studio itself, etc.,

● Open Android Studio


● Click Preferences → Plugins
● Select the Flutter plugin and click Install
● Click Yes when prompted to install the Dart plugin.
● Restart Android studio

Result:
Thus, installation of Flutter/Kotlin multi-platform environment successfully completed.
Ex.No:2 Develop an application that uses Widgets, GUI components, Fonts, and Colors.

Aim:

To develop a Simple Android Application that uses GUI components, Font and Colors.

Procedure:

Creating a New project:

▪ Open Android Stdio and then click on File -> New -> New project.

▪ Then type the Application name as “ex.no.1″ and click Next.

▪ Then select the Minimum SDK as shown below and click Next.
▪ Then select the Empty Activity and click Next.

▪ Finally click Finish.


▪ It will take some time to build and load the project.
▪ After completion it will look as given below.

Designing layout for the Android Application:

▪ Click on app -> res -> layout -> activity_main.xml.

▪ Now click on Text as shown below.


▪ Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:
?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:gravity="center"
android:text="Hello World!"
android:textSize="25sp"
android:textStyle="bold" />

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Change font size"
android:textSize="25sp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Change color"
android:textSize="25sp" />
</LinearLayout>
▪ Now click on Design and your application will look as given below.
▪ So now the designing part is
completed. Java Coding for the Android
Application:

▪ Click on app -> java -> com.example.exno1 -> MainActivity.

▪ Then delete the code which is there and type the code as given below.
Code for MainActivity.java:
?
package com.example.exno1;

import android.graphics.Color;
import
android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import
android.widget.Button;
import
android.widget.TextView;

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

final TextView t= (TextView)


findViewById(R.id.textView); Button b1= (Button)
findViewById(R.id.button1); b1.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
t.setTextSize(font);
font = font + 5;
if (font == 50)
font = 30;
}
});
Button b2= (Button) findViewById(R.id.button2);
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (ch) {
case 1:
t.setTextColor(Color.RED);
break;
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++;
if (ch == 7)
ch = 1;
}
});
}
}
▪ So now the Coding part is also completed.
▪ Now run the application to see the output.
Output:
Result:

Thus a Simple Android Application that uses GUI components, Font and Colors is developed and
executed successfully.
Ex.No:3 Develop a native calculator application.

Aim:

To develop a Simple Android Application for Native Calculator.

Procedure:

Creating a New project:

▪ Open Android Stdio and then click on File -> New -> New project.

▪ Then type the Application name as “ex.no.3″ and click Next.

▪ Then select the Minimum SDK as shown below and click Next.
▪ Then select the Empty Activity and click Next.

▪ Finally click Finish.


▪ It will take some time to build and load the project.
▪ After completion it will look as given below.

Designing layout for the Android Application:

▪ Click on app -> res -> layout -> activity_main.xml.

▪ Now click on Text as shown below.


▪ Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:
▪ ?
▪ <?xml version="1.0" encoding="utf-8"?>
▪ <LinearLayout
▪ xmlns:android="http://schemas.android.com/apk/res/android"
▪ android:orientation="vertical"
▪ android:layout_width="match_parent"
▪ android:layout_height="match_parent"
▪ android:layout_margin="20dp">

▪ <LinearLayout
▪ android:id="@+id/linearLayout1"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_margin="20dp">

▪ <EditText
▪ android:id="@+id/editText1"
▪ android:layout_width="match_parent"

▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:inputType="numberDecimal"
▪ android:textSize="20sp" />

▪ <EditText
▪ android:id="@+id/editText2"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:inputType="numberDecimal"
▪ android:textSize="20sp" />

▪ </LinearLayout>

▪ <LinearLayout
▪ android:id="@+id/linearLayout2"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"

▪ android:layout_margin="20dp">

▪ <Button
▪ android:id="@+id/Add"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="+"
▪ android:textSize="30sp"/>

▪ <Button
▪ android:id="@+id/Sub"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="-"
▪ android:textSize="30sp"/>

▪ <Button
▪ android:id="@+id/Mul"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="*"
▪ android:textSize="30sp"/>

▪ <Button
▪ android:id="@+id/Div"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="/"
▪ android:textSize="30sp"/>

▪ </LinearLayout>

▪ <TextView
▪ android:id="@+id/textView"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_marginTop="50dp"
▪ android:text="Answer is"
▪ android:textSize="30sp"
▪ android:gravity="center"/>

▪ </LinearLayout>
▪ ?
▪ <?xml version="1.0" encoding="utf-8"?>
▪ <LinearLayout
▪ xmlns:android="http://schemas.android.com/apk/res/android"
▪ android:orientation="vertical"
▪ android:layout_width="match_parent"
▪ android:layout_height="match_parent"
▪ android:layout_margin="20dp">

▪ <LinearLayout
▪ android:id="@+id/linearLayout1"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_margin="20dp">

▪ <EditText
▪ android:id="@+id/editText1"
▪ android:layout_width="match_parent"

▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:inputType="numberDecimal"
▪ android:textSize="20sp" />

▪ <EditText
▪ android:id="@+id/editText2"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:inputType="numberDecimal"
▪ android:textSize="20sp" />

▪ </LinearLayout>

▪ <LinearLayout
▪ android:id="@+id/linearLayout2"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"

▪ android:layout_margin="20dp">

▪ <Button
▪ android:id="@+id/Add"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="+"
▪ android:textSize="30sp"/>

▪ <Button
▪ android:id="@+id/Sub"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="-"
▪ android:textSize="30sp"/>

▪ <Button
▪ android:id="@+id/Mul"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="*"
▪ android:textSize="30sp"/>

▪ <Button
▪ android:id="@+id/Div"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_weight="1"
▪ android:text="/"
▪ android:textSize="30sp"/>

▪ </LinearLayout>

▪ <TextView
▪ android:id="@+id/textView"
▪ android:layout_width="match_parent"
▪ android:layout_height="wrap_content"
▪ android:layout_marginTop="50dp"
▪ android:text="Answer is"
▪ android:textSize="30sp"
▪ android:gravity="center"/>

▪ </LinearLayout>
▪ cNow click on Design and your application will look as given below.

▪ So now the designing part is


completed. Java Coding for the Android
Application:

▪ Click on app -> java -> com.example.exno3 -> MainActivity.

▪ Then delete the code which is there and type the code as given below.
Code for MainActivity.java:
?
package com.example.devang.exno3;

import android.os.Bundle;
import
android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import
android.view.View.OnClickListener;
import android.widget.Button;
import
android.widget.EditText;
import
android.widget.TextView;

public class MainActivity extends AppCompatActivity implements OnClickListener


{
//Defining the Views
EditText Num1;
EditText Num2;
Button Add;

Button Sub;
Button Mul;
Button Div;
TextView Result;

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

//Referring the Views


Num1 = (EditText)
findViewById(R.id.editText1); Num2 =
(EditText) findViewById(R.id.editText2);
Add = (Button) findViewById(R.id.Add);
Sub = (Button) findViewById(R.id.Sub);
Mul = (Button) findViewById(R.id.Mul);
Div = (Button) findViewById(R.id.Div);
Result = (TextView) findViewById(R.id.textView);

// set a listener
Add.setOnClickListener(this);
Sub.setOnClickListener(this);
Mul.setOnClickListener(this);
Div.setOnClickListener(this);
}

@Override
public void onClick (View v)
{

flo num1 = 0;
at num2 = 0;
flo result = 0;
at
flo
at
String oper = "";

// check if the fields are empty


if (TextUtils.isEmpty(Num1.getText().toString()) || TextUtils.isEmpty(Num2.getText().toString()))
return;

// read EditText and fill variables with numbers


num1 =
Float.parseFloat(Num1.getText().toString());
num2 =
Float.parseFloat(Num2.getText().toString());

// defines the button that has been clicked and performs the corresponding operation
// write operation into oper, we will use it later for output
switch (v.getId())
{
case R.id.Add:
oper = "+";
result = num1 + num2;
break;
case R.id.Sub:
oper = "-";
result = num1 - num2;
break;
case R.id.Mul:
oper = "*";
result = num1 * num2;
break;
case R.id.Div:
oper = "/";
result = num1 / num2;
break;
default:
break;
}
// form the output line
Result.setText(num1 + " " + oper + " " + num2 + " = " + result);
}
}
▪ So now the Coding part is also completed.
▪ Now run the application to see the output.
Output:
Result:

Thus a Simple Android Application for Native Calculator is developed and executed successfully.
Ex.No:4 Develop a gaming application that uses 2-D animations and gestures Aim:
To develop a gaming application that uses 2-D animations and gestures

Aim:
To Develop a gaming application that uses 2-D animations and gestures.

Program :
activity_main.xml:

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/scoreText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Score: 0"
android:textSize="24sp"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/timerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time: 30"
android:textSize="24sp"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:layout_centerHorizontal="true"/>
<View
android:id="@+id/ball"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:background="@drawable/ball"/>
</RelativeLayout>

ball.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF5722"/>
<corners android:radius="50dp"/>
</shape>

MainActivity.java:
package com.example.simplegame;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
private TextView scoreText;
private TextView timerText;
private View ball;
private int score = 0;
private int timeRemaining = 30;
private boolean isGameRunning = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scoreText = findViewById(R.id.scoreText);
timerText = findViewById(R.id.timerText);
ball = findViewById(R.id.ball);
startGameTimer();
ball.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isGameRunning) {
score++;
scoreText.setText("Score: " + score);
moveBall();
}
}
});
}
private void startGameTimer() {
final Handler handler = new Handler();
Runnable timerRunnable = new Runnable() {
@Override
public void run() {
if (timeRemaining > 0) {
timeRemaining--;
timerText.setText("Time: " + timeRemaining);
handler.postDelayed(this, 1000); // Update every second
} else {
endGame();
}
}
};
handler.post(timerRunnable);
}
private void moveBall() {
int screenWidth = getResources().getDisplayMetrics().widthPixels;
int screenHeight = getResources().getDisplayMetrics().heightPixels;
Random random = new Random();
int x = random.nextInt(screenWidth - ball.getWidth());
int y = random.nextInt(screenHeight - ball.getHeight());
ball.setX(x);
ball.setY(y);
}
private void endGame() {
isGameRunning = false;
Toast.makeText(this, "Game Over! Final Score: " + score, Toast.LENGTH_SHORT).show();
}
}
OUTPUT:

Result:
Successfully Develop a gaming application that uses 2-D animations and gestures
Ex.No: 5 Develop a movie rating application (similar to
IMDB) Aim:
To develop a movie rating application.
Procedure:
MainActivity.java
<RelativeLayout
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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Choose one of the following modes"
android:textAppearance="?android:attr/textAppearanceLarge" />

<RadioGroup
android:id="@+id/myRadioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginLeft="27dp"
android:layout_marginTop="28dp">

<RadioButton
android:id="@+id/sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Sound" />

<RadioButton
android:id="@+id/vibrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vibration" />

<RadioButton
android:id="@+id/silent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Silent" />
</RadioGroup>

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/myRadioGroup"
android:layout_below="@+id/myRadioGroup"
android:layout_marginLeft="42dp"
android:layout_marginTop="53dp"
android:text="choose" />
</RelativeLayout>
package com.example.myapplication;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {


private RadioGroup radioGroup;
private RadioButton sound, vibration, silent;
private Button button;
private TextView textView;

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

radioGroup = (RadioGroup) findViewById(R.id.myRadioGroup);


sound = (RadioButton) findViewById(R.id.sound);
vibration = (RadioButton) findViewById(R.id.vibrate);
silent = (RadioButton) findViewById(R.id.silent);
textView = (TextView) findViewById(R.id.textView1);
button = (Button) findViewById(R.id.button1);

radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// find which radio button is selected
if (checkedId == R.id.silent) {
Toast.makeText(getApplicationContext(), "choice: Silent", Toast.LENGTH_SHORT).show();
} else if (checkedId == R.id.sound) {
Toast.makeText(getApplicationContext(), "choice: Sound", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "choice: Vibration", Toast.LENGTH_SHORT).show();
}
}
});

button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int selectedId = radioGroup.getCheckedRadioButtonId();

// find which radio button is checked by id


if (selectedId == sound.getId()) {
textView.setText("You chose 'Sound' option");
} else if (selectedId == vibration.getId()) {
textView.setText("You chose 'Vibration' option");
} else {
textView.setText("You chose 'Silent' option");
}
}
});
}
}

OUTPUT:
Result:
Thus, the program was executed and implemented successfully.
Ex.No: 6 Develop an application to connect to a web service and to retrieve data
with HTTP
Aim:
To develop an application to connect to a web service and to retrieve data with
HTTP

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. 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.admin.myapplication;

import
android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import
android.view.View;
import
android.widget.Button;
import
android.widget.Toast;

public class MainActivityextends

AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button startBtn = (Button) findViewById(R.id.sendbttn);
startBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
sendEmail();
}
});
}

protected void sendEmail() {


Log.i("Send email", "");
String[] TO = {

"muthuramalingam566@gmail.com"
};
String[] CC = {

"ramdurai25@gmail.com"
};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here");
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex)
{ Toast.makeText(MainActivity.this, "There is no email client
installed.", Toast.LENGTH_SHORT).show();
}
}
}

activity_main.xml

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


<RelativeLayoutxmlns: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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.admin.myapplication.MainActivity">
<EditTextandroid:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"

android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10" android:id="@+id/editText2"
android:layout_below="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_alignEnd="@+id/editText" />
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10" android:id="@+id/editText3"
android:layout_below="@+id/editText2"
android:layout_alignRight="@+id/editText2"
android:layout_alignEnd="@+id/editText2" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEND MAIL"
android:id="@+id/sendbttn"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/editText3"
android:layout_alignStart="@+id/editText3" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Recipient"
android:id="@+id/textView"
android:layout_alignBottom="@+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="subject"
android:id="@+id/textView2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message Body"
android:id="@+id/textView3"
android:layout_alignBottom="@+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>

OUTPUT:
Result:
Thus, the program was implemented and executed successfully.
Ex.No: 7 Develop a simple shopping
application Aim:
To develop a simple shopping application
Procedure:
MainActivity.java
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world" />

<Button
android:id="@+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="299dp"
android:layout_marginEnd="120dp"
android:text="Item 1" />

<Button
android:id="@+id/item2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/item1"
android:layout_alignParentEnd="true"
android:layout_marginTop="12dp"
android:layout_marginEnd="128dp"
android:text="Item 2" />

<Button
android:id="@+id/item3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="98dp"
android:layout_marginBottom="146dp"
android:text="Item 3" />

</RelativeLayout>

package com.example.optionmenue;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

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

// Find the buttons by their IDs


Button button1 = findViewById(R.id.item1);
Button button2 = findViewById(R.id.item2);
Button button3 = findViewById(R.id.item3);

// Set click listeners for each button


button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Action to perform when button1 is clicked
Toast.makeText(MainActivity.this, "Button 1 clicked", Toast.LENGTH_SHORT).show();
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Action to perform when button2 is clicked
Toast.makeText(MainActivity.this, "Button 2 clicked", Toast.LENGTH_SHORT).show();
}
});

button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Action to perform when button3 is clicked
Toast.makeText(MainActivity.this, "Button 3 clicked", Toast.LENGTH_SHORT).show();
}
});
}
}

OUTPUT:
Result:
Thus, the program was implemented and executed successfully
Ex.No: 8 Design a web server supporting push notifications.

Aim:
To develop a web server supporting push notifications.

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.
7. Close the Android project.

PROGRAM CODE:
MainActivity.java
<?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" >

<EditText
android:id="@+id/emailInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />

<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20sp"
android:gravity="center"
android:text="Login" />

</LinearLayout>

package com.example.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;

@Override
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() {
@Override
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(),second_activity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "Login Success", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Please Enter valid email",
Toast.LENGTH_LONG).show();
}
}
});
}
}

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


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<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.Alert"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>

OUTPUT:
Result:
Thus, the program was implemented and executed successfully.
Ex.No: 9 Develop an application by integrating Google maps

AIM:
To develop an android application that uses Google Map location information.

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.

PROGRAM CODE

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


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

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Emergency Alert System" />

<EditText
android:id="@+id/editTextSMS"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top" />

<EditText
android:id="@+id/textlon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top" />

<Button
android:id="@+id/buttonSend"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Send" />

</LinearLayout>

package com.example.emergency;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;

public class MainActivity extends Activity {


Button buttonSend;
EditText textSMS;
EditText textlon;
LocationManager mlocManager;

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

buttonSend = (Button) findViewById(R.id.buttonSend);


textSMS = (EditText) findViewById(R.id.editTextSMS);
textlon = (EditText) findViewById(R.id.textlon);

mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);


LocationListener mlocListener = new MyLocationListener();
if (ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
}
public class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
loc.getLatitude();
loc.getLongitude();
Double lat = loc.getLatitude();
Double lon = loc.getLongitude();
textSMS.setText(lat.toString());
textlon.setText(lon.toString());
}

@Override
public void onProviderDisabled(String provider) {
Toast.makeText(getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT).show();
}

@Override
public void onProviderEnabled(String provider) {
Toast.makeText(getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show();
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// Not implemented, but required to override abstract method
}
}
}
OUTPUT:
Result:

Thus, the program for android application that makes use of Google Map was
executed successfully.
Ex.No: 10 Mini Projects involving Flutter/Kotlin multi-

platform AIM:

To Write a mobile application that creates alarm clock.

PROCEDURE:

Create a new Android Application


1. In Eclipse go to File->New->Project
2. Select an Android Project from the Android Folder and press Next.
3. Fill in the details of your Android application.
a. Project Name: The project name and folder that Eclipse will store the project files
b. Build Target: The version of the Android SDK that will be used when you
build your program. Select a platform that is equal to or lower than the target
chosen for the AVD.
c. Application Name: This is the name of the application.
d. Package Name: The namespace that all of the source code will reside under.
e. Create Activity: The name for that class stub that is generated by the plugin.
4. The values that are used in this example are:
a. Project Name: Alarm
b. Build Target: 2.3.3
c. Application Name: Alarm
d. Package Name: com. Alarm.example
e. Create Activity: Alarm
5. Click on
Finish. Coding
the
Application
1. Open AndroidMainfest.xml which is located in res->values-> AndroidMainfest.xml.
This file will hold all of the text that our layout will use.
2. Click on the AndroidMainfest.xml at the bottom to bring up the raw xml file.

Editing the the java code

1. Open SampleApp.java from the left hand side.


2. Save the files.

Running the Application

1. Click on the green circle with the white arrow.


2. Choose the AVD that we created in a previous step.
3. The android AVD will load and the program will run.
PROGRAMS

FileName :MainActivity.java

Package
com.lab.alarmclock;
import
java.util.Calendar;
import
android.app.Activity;
import
android.app.AlarmManager;
import
android.app.PendingIntent;
import
android.content.Context;
import
android.content.Intent;
import android.os.Bundle;
import android.view.View;
import
android.view.View.OnClickListe
ner; import
android.widget.Button; import
android.widget.TimePicker;

public class AlarmActivity extends


Activity
{

private TimePicker
timepicker; private
Context context; private
Button btnSetAlarm;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

context = this;

timepicker = (TimePicker) findViewById(R.id.timepicker);

btnSetAlarm = (Button)
findViewById(R.id.btnSetAlarm);
btnSetAlarm.setOnClickListener(new
OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,
timepicker.getCurrentHour());
calendar.set(Calendar.MINUTE,
timepicker.getCurrentMinute());

Intent myIntent = new Intent(context,


AlarmReceiver.class); PendingIntent pendingIntent =
PendingIntent.getBroadcast(
context, 0, myIntent, 0);

AlarmManager
alarmManager = (AlarmManager)
getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC,
calendar.getTimeInMillis(), pendingIntent);

}
});

};}
}

File Name: Alaram Reciever.java

package com.lab.alarmclock;

import
android.content.Context;
import
android.content.Intent;
import
android.media.Ringtone;
import
android.media.RingtoneManager
; import android.net.Uri;
import
android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
import android.widget.Toast;

public class AlarmReceiver

extends

WakefulBroadcastReceiver { @Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.e("alarmreceiver", "alarmreceiver");
Toast.makeText(context, "alarmreceiver", Toast.LENGTH_LONG).show();

Uri alarmUri = RingtoneManager


.getDefaultUri(RingtoneManager.TYPE_ALARM);

Ringtone ringtone = RingtoneManager.getRingtone(context,

alarmUri); ringtone.play();

}
}

File Name: Androidmainfest.xml

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


<manifest
xmlns:android="http://schemas.android.com/apk/res/andr
oid" package="com.lab.alarmclock"
android:versionCode="1
"
android:versionName="
1.0"
>

<uses-permission android:name="android.permission.WAKE_LOCK" />


<uses-sdk
android:minSdkVersion="8
"
android:targetSdkVersion="
21"
/>
<application
android:allowBackup="tru
e"
android:icon="@drawable/
ic_launche r"
android:label="@string/app_nam
e"
android:theme="@style/AppThem
e" >
<activity
android:name=".AlarmActivity"
android:label="@string/app_na
me"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
<receiver android:name=".AlarmReceiver" />
</application>

</manifest>

OUTPUT:
RESULT:

Thus the mobile application that creates alarm


MOBILE APPLICATION DEVELOPMENT LAB VIVA Questions :-
1. What is Android?
It is an open-sourced operating system that is used primarily on mobile devices, such as cell
phones and tablets. It is a Linux kernel-based system that’s been equipped with rich
components that allows developers to create and run apps that can perform both basic and
advanced functions.
2. What Is the Google Android SDK?
The Google Android SDK is a toolset that developers need in order to write apps on Android
enabled devices. It contains a graphical interface that emulates an Android driven handheld
environment, allowing them to test and debug their codes.
3. What is the Android Architecture?
Android Architecture is made up of 4 key components:
1. Linux Kernel
2. Libraries
3. Android Framework
4. Android Applications
4. Describe the Android Framework.
The Android Framework is an important aspect of the Android Architecture. Here you can
find all the classes and methods that developers would need in order to write applications on
the Android environment.
5. What is AAPT?
AAPT is short for Android Asset Packaging Tool. This tool provides developers with the
ability to deal with zip-compatible archives, which includes creating, extracting as well as
viewing its contents.
6. What is the importance of having an emulator within the Android environment?
The emulator lets developers “play” around an interface that acts as if it were an actual
mobile device. They can write and test codes, and even debug. Emulators are a safe place for
testing codes especially if it is in the early design phase.
7. What is the use of an activityCreator?
An activity Creator is the first step towards the creation of a new Android project. It is made
up of a shell script that will be used to create new file system structure necessary for writing
codes within the Android IDE.
8 . Describe Activities.
Activities are what you refer to as the window to a user interface. Just as you create windows
in order to display output or to ask for an input in the form of dialog boxes, activities play the
same role, though it may not always be in the form of a user interface.
9. What are Intents?
Intents displays notification messages to the user from within the Android enabled device. It
can be used to alert the user of a particular state that occurred. Users can be made to respond
to intents.
10. Differentiate Activities from Services.
Activities can be closed, or terminated anytime the user wishes. On the other hand, services
are designed to run behind the scenes, and can act independently. Most services run
continuously, regardless of whether there are certain or no activities being executed.
11. What items are important in every Android project?
These are the essential items that are present each time an Android project is created:
● Android Manifest.xml
● build.xml
● bin/
● src/
● res/
● assets/
12. What is the importance of XML-based layouts?
The use of XML-based layouts provides a consistent and somewhat standard means of setting
GUI definition format. In common practice, layout details are placed in XML files while
other items are placed in source files.
13. What are containers?
Containers, as the name itself implies, holds objects and widgets together, depending on
which specific items are needed and in what particular arrangement that is wanted.
Containers may hold labels, fields, buttons, or even child containers, as examples.
14. What is Orientation?
Orientation, which can be set using set Orientation(), dictates if the Linear Layout is
represented as a row or as a column. Values are set as either HORIZONTAL or VERTICAL.
15. What is the importance of Android in the mobile market?
Developers can write and register apps that will specifically run under the Android
environment. This means that every mobile device that is Android enabled will be able to
support and run these apps. With the growing popularity of Android mobile devices,
developers can take advantage of this trend by creating and uploading their apps on the
Android Market for distribution to anyone who wants to download it.
16. What do you think are some disadvantages of Android?
Given that Android is an open-source platform, and the fact that different Android operating
systems have been released on different mobile devices, there’s no clear cut policy to how
applications can adapt with various OS versions and upgrades.
–> One app that runs on this particular version of Android OS may or may not run on another
version.
–> Another disadvantage is that since mobile devices such as phones and tabs come in
different sizes and forms, it poses a challenge for developers to create apps that can adjust
correctly to the right screen size and other varying features and specs.
17. What is adb?
Adb is short for “Android Debug Bridge”. It allows developers the power to execute remote
shell commands. Its basic function is to allow and control communication towards and from
the emulator port.
18. What are the four essential states of an activity?
1. Active – if the activity is at the foreground
2. Paused – if the activity is at the background and still visible
3. Stopped – if the activity is not visible and therefore is hidden or obscured by another
activity
4. Destroyed – when the activity process is killed or completed terminated
19. What is ANR?
ANR is short for Application Not Responding. This is actually a dialog that appears to the
user whenever an application have been unresponsive for a long period of time.
20. Which elements can occur only once and must be present?
Among the different elements, the and elements must be present and can occur only once.
The rest are optional, and can occur as many times as needed.
21. How are escape characters used as attribute?
Escape characters are preceded by double backslashes. For example, a newline character is
created using ‘\\n’
22. What is the importance of settings permissions in app development?
Permissions allow certain restrictions to be imposed primarily to protect data and code.
Without these, codes could be compromised, resulting to defects in functionality.
23. What is the function of an intent filter?
Because every component needs to indicate which intents they can respond to, intent filters
are used to filter out intents that these components are willing to receive. One or more intent
filters are possible, depending on the services and activities that is going to make use of it.
24. Enumerate the three key loops when monitoring an activity?
● Entire lifetime – activity happens between on Create and on Destroy

● Visible lifetime – activity happens between on Start and on Stop


● Foreground lifetime – activity happens between on Resume and on Pause
25. When is the on Stop(. method invoked?
A call to on Stop method happens when an activity is no longer visible to the user, either
because another activity has taken over or if in front of that activity.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy