0% found this document useful (0 votes)
31 views39 pages

Application Developmen Lab 1

Uploaded by

seenu
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)
31 views39 pages

Application Developmen Lab 1

Uploaded by

seenu
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/ 39

EASWARI ENGINEERING COLLEGE

[An Autonomous Instituition]


RAMAPURAM, CHENNAI-89

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

LAB MANUAL

191CSC611L
APPLICATION DEVELOPMENT LABORATORY (MOBILE/WEB)

2021-2022 (EVEN SEM)

Prepared By Approved by

Ms.S.Bhuvaneswari, Assistant Professor /CSE


Ms. A.Abirami, Assistant Professor / CSE HOD/CSE
191CSC611L
APPLICATION DEVELOPMENT LABORATORY L T P R C

0 0 3 1 2
OBJECTIVES:

The student should be made to:

 To understand the components and structure of mobile application development frameworks for
Android and windows OS based mobiles.
 To understand how to work with various mobile application development frameworks.
 To learn the basic and important design concepts and issues of development of mobile applications.
 To understand the capabilities and limitations of mobile devices.

LIST OF EXPERIMENTS:

1. Develop an application that uses GUI components, Layout Managers and event listeners.
2. Develop an application to simulate a keyboard.
3. Create an application that uses graphical primitives.
4. Develop an application that makes use of databases.
5. Implement an application that uses Multi-threading.
6. Develop a native application that uses GPS location information.
7. Implement an application that writes data to the SD card.
8. Implement an application that send a SMS and creates an alert upon receiving the SMS.
9. Create an application that makes use of Menu.
10. Develop an application to build an alarm clock.
11. Implement a hybrid mobile application for displaying a website.
12. Mini Project (Food delivery app, Attendance tracking app, Online ticket booking app etc.)

TOTAL: 60PERIODS
OUTCOMES:
At the end of the course, the student should be able to:

1. Develop mobile applications using GUI and Layouts.


2. Develop mobile applications using Event Listener.
3. Develop mobile applications using Databases.
4. Develop mobile applications using RSS Feed, Internal/External Storage, SMS, Multithreading and GPS.
5. Analyze and discover own mobile app for simple needs.
LIST OF EQUIPMENT FOR A BATCH OF 30 STUDENTS:
 SOFTWARE: C / C++ / Java or equivalent compiler GnuPG, Snort, N-Stalker or Equivalent
 HARDWARE: Standalone desktops – 30 Nos. (or) Server supporting 30 terminals or more.

REFERENCES:

Build Your Own Security Lab, Michael Gregg, Wiley India

CONTENT BEYOND SYLLABUS

 Develop a native calculator application.

 Write a mobile application that creates alarm clock

MINI PROJECTS

 Android-based Prescription Viewer Application


 Children Tracking System Using Bluetooth MANET Composed of Android Mobile
Terminals
 Authentication Schemes for Session Passwords using Color and Images by Android
 Android Suburban Railway Ticketing with GPS as Ticket Checker
 Android System Design and Implementation for Telemetric Services
 Automatic Brightness Control of the Hand-held Device Display with Low Illumination
 Network-Assisted Mobile Computing with Optimal Uplink Query Processing
 A Personalized Mobile Search Engine (PMSE)
 Network Behavior Analysis for Android Malware Detection
 Distributed Web Systems Performance Forecasting Using Turning Bands Method
 War Field Spying Robot with Night Vision Wireless Camera By Android Application

 Pick and Place Robotic Arm Controlled by Wireless Android Application

 Remote Operated Domestic Appliances Control by Using Android Application

 Smart Travel Guide Application for Android Mobile


 Android Phone Based Home Surveillance System

 Android Based Remote Monitoring System

 Automatic Number Plate Recognition on Android Platform


 Implementation of Cuff less Continuous Blood Pressure Measurement System based on
Android
 Indoor Wi-Fi Positioning System For Android-Based Smartphone

 Design and Development of Android Application based Wireless Toy Car

 Android Based Electronic Fare Meter System:


 Automated Car Parking System Commanded by Android Application

 Android Application for Doctors Appointment


EASWARI ENGINEERING COLLEGE
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
COURSE PLAN
Regulation – 2019

COURSE/ : B.E Computer science and Total number of hours given in the
BRANCH Engineering syllabus
SUBJECT CODE : 191CSC611 L Lecture : -
SUBJECT TITLE : Application Development Tutorials : -
laboratory
YEAR/SEMESTER : III/6 Practical : 60
FACULTY NAME : Ms.S.Bhuvaneswari Total : 60
Ms.A.Abirami
Mr.P.Harikumar

COURSE OBJECTIVES:
 To understand the components and structure of mobile application development frameworks for
Android and windows OS based mobiles.
 To understand how to work with various mobile application development frameworks.
 To learn the basic and important design concepts and issues of development of mobile
applications.
 To understand the capabilities and limitations of mobile devices

S.N LIST OF EXPERIMENTS RELEVANCE CO’S


O
1 Develop an application that uses GUI components, Layout CO1, CO2
Managers and event listeners.
2 Develop an application to simulate a keyboard. CO1, CO2
3 Create an application that uses graphical primitives. CO1,CO3
4 Develop an application that makes use of databases. CO1,CO3
5 Implement an application that uses Multi-threading. CO1,CO3
6 Develop a native application that uses GPS location CO1, CO2, CO4
information.
7 Implement an application that writes data to the SD card. CO1, CO4
8 Implement an application that send a SMS and creates an alert CO1, CO2, CO4
upon receiving the SMS.
9 Create an application that makes use of Menu. CO1, CO2, CO3
10 Develop an application to build an alarm clock. CO1, CO4
11 Implement a hybrid mobile application for displaying a CO1, CO2, CO4
website.
12 Mini Project (Food delivery app, Attendance tracking app, CO5
Online ticket booking app etc.)

Course Outcomes:
Develop mobile applications using GUI and Layouts.
Develop mobile applications using Event Listener.
Develop mobile applications using Databases.
Develop mobile applications using RSS Feed, Internal/External Storage, SMS, Multithreading and GPS.
Analyze and discover own mobile app for simple needs.

Program Outcomes:
PO1 : Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization to the solution of complex engineering problems.

PO2 : Problem analysis: Identify, formulate, research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics, natural
sciences, and engineering sciences.

PO3 : 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.

PO4 : 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.

PO5 : 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.

PO6 :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.

PO7: 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.
PO8 : Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.

PO9 : Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.

PO10 : 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.

PO11: 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.

PO12 : 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
EX.NO. 1 DEVELOP AN APPLICATION THAT USES GUI COMPONENTS, LAYOUT
MANAGERS AND EVENT LISTENERS.

AIM:

To develop an application that uses GUI components, layout managers and event listeners.

PROCEDURE:
1) Open android studio and select new android project
2) Give project name and package name.
3) UI design for android application is done using a layout xml file. Android studio offers a layout editor
which allows you to drag and drop UI elements into the interface.
Widgets:

 TextView
 Button
 RadioButton
 ToggleButton
 ImageView
 ImageButton
 CheckBox
 ProgressBar
 SeekBar
 RatingBar
 WebView
 Spinner
Text Fields:

 EditText, Plain text, Name, Number, Email etc.


 Containers
 ScrollView
 Vertical
 Horizontal
 ListView
 GridView
 SearchView
 TabHost
Common Attributes:
 Layout Width
 Layout Height
 Gravity
 centre
 left
 right etc.
 match_parent
 fill_parent
 wrap_content
 <<pixel value>> in dp
 style
 uses drawable.
 background
 color or drawable.
 id
 padding
 margin
 textColor
 color value (Hex,Rgba etc.)
 drawable
 color resource
 textStyle

 typeface
4) Create the activity_main.xml file and MainActivity.java file
5) Run the application
package com.example.font1;
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.button); 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;
Layouts

1. Relative Layout
As in name this layout positions elements relative to the adjacent elements. It uses the following
attributes for each element to position them:

 layout:alignEnd
 layout:alignStart
 layout:toEndOf
 layout:toStartOf
 layout:alignParent
 layout:centreInParent

2. Linear Layout

Linear layouts are two types Horizontal and Vertical. Horizontal/Vertical is set using the orientation
attribute. In such layout the elements are arranged in order toptobottom or lefttoright. Let’s add a Linear
Layout now. (Now you can use the drag and drop layout editor). Change orientation to Vertical. Now add
an ImageView to the Linear Layout. Import an image to the drawable directory. Set the src attribute to
the drawable we imported. (Click the browse button and select the file from Drawable directory).

3. Table Layout

As we all know table layout uses rows and columns to position elements. Add table layout inside the
linear layout. Table layout uses TableRow layout to create rows. Add a TableRow to the TableLayout.
Add two Buttons to the TableRow.Change the Id’s of the two Buttons to btnClick and btnLongClick
respectively. We will use these buttons to implement event listeners
Change text to Click Me! and Long Click Me! also. Select one of the buttons from the component tree.
Pay attention to Properties window. You can see layout:span and layout:column attributes. The table
layout uses these attributes to position elements. If the values are unset then uses default values (span=1
and column increments according to order of placement).

4. Grid Layout

This is a very useful layout. This layout has order as well as freedom. This layout uses orderly grids with
rows and columns, span and spaces. Add a GridLayout below the table layout. Now drag and drop a
Button to the GridLayout.
You’ll see a green grid with many blocks.

Event Listeners
Two most commonly used event listeners – onClickEventListener() and
onLongClickEventListener(). Step 1:

First we need to define some variables for each items in the UI.
Button clickBtn, longClickBtn, allBtn, btnShow;
TextView sample;
EditText nameTxt;

Step 2:
Assign the UI elements to these variables using findViewById()
clickBtn = (Button) findViewById(R.id.btnClick);
longClickBtn = (Button) findViewById(R.id.btnLongClick);
allBtn = (Button) findViewById(R.id.btnAll);
btnShow = (Button) findViewById(R.id.btnShowName);
sample = (TextView) findViewById(R.id.txtSample);
nameTxt = (EditText) findViewById(R.id.txtName);

Step 3:
Implementing the onClick Listener:
/*Simple Click onClick Listener*/
clickBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Hai John!", Toast.LENGTH_SHORT).show();
}
});
This event listener toasts a message Hai John when the “Click Me!” button is clicked

Step 4:
Implementing the onLongClick Listener
/*Implement Long Click Listener*/
longClickBtn.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v)
{ Toast.makeText(getApplicationContext(), "Hai
there!", Toast.LENGTH_SHORT).show();
return false;
}
});
This
event listener toasts a message “Hai there!” when the “Long Click Me!” button is clicked and held.

Step 5:
Implementing onClick and onLongClick Event on the same button.
allBtn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v)
{ Toast.makeText(getApplicationContext(), "You Just Clicked
Me!", Toast.LENGTH_SHORT).show();
}
});
allBtn.setOnLongClickListener(new View.OnLongClickListener()
{ @Override
public boolean onLongClick(View v)
{ Toast.makeText(getApplicationContext(), "You clicked me for so
long!", Toast.LENGTH_SHORT).show();
return false;
}
});
The button defined by the variable allBtn will toast two different messages when clicked
and longclicked
i.e, “You just Clicked Me!” when clicked and “You clicked me for so long!”
when long clicked.
Step 6:
Reading a data from a text field and writing it to a text view using event listeners.
btnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sample.setText(nameTxt.getText().toString());
}
});
This event reads the value of the nameTxt text field and writes it to sample TextView.

RESULT:
Thus the program to create a Mobile App to display GUI components anddifferent layouts is executed
successfully.
EX.NO.2 DEVELOP AN APPLICATION TO STIMULATE A KEYBOARD

AIM:

To develop an application to stimulate a keyboard.

PROCEDURE:

1. In Open android studio and create a new project.


2. Select empty activity and click next.
3. In the configure your project window ,enter the app and package name and select java from language
drop down menu and click finish.
4. Create a parent layout ,linear layout to create virtual keyboard.
5. 5.Add the text view , edit text and button.
6. Add on event listener for the button in java code using click listener.
7. Save and Run the project.

PROGRAM:
Activity_main.xml:

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


<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:text="1"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="129dp"
android:layout_marginEnd="25dp"
android:text="2"
app:layout_constraintEnd_toStartOf="@+id/button3"
app:layout_constraintStart_toEndOf="@+id/button1"
app:layout_constraintTop_toBottomOf="@+id/editTexts" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="36dp"
android:text="3"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.23"
app:layout_constraintStart_toEndOf="@+id/button2" />

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:text="4"
app:layout_constraintBaseline_toBaselineOf="@+id/button5"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp"
android:text="5"
app:layout_constraintEnd_toStartOf="@+id/button6"
app:layout_constraintStart_toEndOf="@+id/button4"
app:layout_constraintTop_toBottomOf="@+id/button2" />

<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="36dp"
android:text="6"
app:layout_constraintBaseline_toBaselineOf="@+id/button5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button5" />

<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:text="7"
app:layout_constraintBaseline_toBaselineOf="@+id/button8"
app:layout_constraintStart_toStartOf="parent" />
<Button

android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp"
android:text="8"
app:layout_constraintEnd_toStartOf="@+id/button9"
app:layout_constraintStart_toEndOf="@+id/button7"
app:layout_constraintTop_toBottomOf="@+id/button5" />

<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="36dp"
android:text="9"
app:layout_constraintBaseline_toBaselineOf="@+id/button8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button8" />

<Button
android:id="@+id/button0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button8" />

<Button
android:id="@+id/button11"
android:layout_width="153dp"
android:layout_height="52dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="20dp"
android:text="Delete"
app:layout_constraintBaseline_toBaselineOf="@+id/button12"
app:layout_constraintEnd_toStartOf="@+id/button12"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button12"
android:layout_width="148dp"
android:layout_height="52dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="40dp"
android:text="Enter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button0"
app:layout_constraintVertical_bias="0.219" />

<EditText
android:id="@+id/editTexts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:layout_marginBottom="50dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Mainactiviy.java

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

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = findViewById(R.id.button1);
Button button2 = findViewById(R.id.button2);
Button button3 = findViewById(R.id.button3);
Button button4 = findViewById(R.id.button4);
Button button5 = findViewById(R.id.button5);
Button button6 = findViewById(R.id.button6);
Button button7 = findViewById(R.id.button7);
Button button8 = findViewById(R.id.button8);
Button button9 = findViewById(R.id.button9);
Button button0 = findViewById(R.id.button0);
Button enter = findViewById(R.id.button12);
Button del = findViewById(R.id.button11);
EditText et=findViewById(R.id.editTexts);

button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"1");
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"2");
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"3");
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"4");
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"5");
}
});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"6");

}
});
button7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"7");
}
});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"8");
}
});
button9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"9");
}
});
button0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.setText(et.getText()+"0");
}
});
del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String textString = et.getText().toString();
if( textString.length() > 0 ) {

et.setText(textString.substring(0, textString.length() - 1 ));


et.setSelection(et.getText().length());//position cursor at the end of the line
}
}

});

enter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
et.append("\n");
}
});

}
}

RESULT: Thus a Mobile App has been developed to stimulate a keyboard successfully and output is
verified.
EX.NO.3 DEVELOP AN APPLICATION THAT DRAWS BASIC
GRAPHICAL PRIMITIVES
AIM:

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

PROCEDURE:

In this exercise we will draw some graphic primitives using Paint, View, Canvas and a method onDraw().
Open the Project Window.
Expand the app and then the java folders.

Right-Click on the empty folder (in your case it will be your package name) and select New then Java
Class.
Name it SampleCanvas and Click OK.
Now we need to Extend the View Class to the SampleC

Now you’ll get a pop-up saying create constructor go ahead and select it.
Now another window will open up with different constructors. Select the one with just a context as
parameter.

Delete the super.onDraw(canvas) .


Now we will start drawing inside the onDraw method:

SET THE PAINT COLOR:

paint.setColor(Color.BLUE);
SET THE STROKE WIDTH:

paint.setStrokeWidth(0);
DRAW A RECTANGLE:

To draw a rectangle we use the function:


canvas.drawRect(float left, float top, float right, float bottom, Paint paint);
The co-ordinates of:
A = (left, top)
B = (right, bottom)
paint is the paint object we created. Lets draw a rectangle now: canvas.drawRect(100,100,300,300,p
aint);
DRAWING A CIRCLE:
METHOD
canvas.drawCircle(float cx, float cy, float radius, Paint paint);
DEPICTION
The co-ordinates of A = (cx,cy).
And the length AB = radius.
Let’s draw a circle with fill color green center at (200,200) and
radius 75.
paint.setColor(Color.GREEN);
canvas.drawCircle(200,200,75,paint);

DRAWING A LINE:
METHOD
canvas.drawLine(float startX, float startY, float stopX, float stopY, Paint paint);
DEPICTION
Draws a line with initial point at (startX, startY) and end point at
(stopX, stopY)
Let’s draw a line from point (100,200) to (300,200)
paint.setColor(Color.BLACK);
canvas.drawLine(100, 200, 300, 200, paint);
MORE GRAPHICS

PAINT.SETCOLOR(GETRESOURCES().GETCOLOR(R.COLOR.TEAL));
//WE SET THIS COLOR BY EDITING THE COLOR.XML FILE INSIDE VALUES DIRECTORY
/**
* <COLOR NAME="TEAL">#00BA92</COLOR>
*/
CANVAS.DRAWTEXT("GRAPHICAL PRIMITIVE",50,50,PAINT);
PAINT.SETCOLOR(COLOR.BLACK);
PAINT.SETSTROKEWIDTH(3);
CANVAS.DRAWPOINT(200,200,PAINT)

RESULT: Thus a Mobile App has been developed to display all the graphics primitives and seen in the
Android Emulator.
EX NO: 4 DEVELOP AN APPLICATION THAT MAKES USE OF
DATABASE
AIM:

To develop an application that makes use of database.

PROCEDURE:

We will use the SQLiteDatabase and SQLiteOpenHelper classes to implement database handling.
Creating database handler class
To handle a database we need to create a database handler class.
So, right click on the package directory (inside java folder) and select New then Java Class

Name it for example MyDBHandler


Now we need to extend the SQLiteOpenHelper class Now these methods are automatically generated for you

Declare some static variables that will save the database and the table details we are going to create.

RESULT:
Thus a Mobile App is developing to display details from a database
EX NO: 6 IMPLEMENT AN APPLICATION THAT IMPLEMENTS
MULTI THREADING
AIM:

To develop an application that implements multithreading.

PROCEDURE:

When an application is launched, the system creates a thread of execution for the application,
called "main." This thread is very important because it is in charge of dispatching events to the
appropriate user interface widgets, including drawing events. It is also the thread in which your
application interacts with components from the Android UI toolkit (components from the android.widget
and android.view packages). As such, the main thread is also sometimes called the UI thread. The system
does not create a separate thread for each instance of a component.
All components that run in the same process are instantiated in the UI thread, and system calls to
each component are dispatched from that thread.
When your app performs intensive work in response to user interaction, this single thread model can yield
poor performance unless you implement your application properly. Specifically, if everything is
happening in the UI thread, performing long operations such as network access or database queries will
block the whole UI.
When the thread is blocked, no events can be dispatched, including drawing events. From the
user's perspective, the application appears to hang. Even worse, if the UI thread is blocked for more than
a few seconds (about 5 seconds currently) the user is presented with the infamous "application not
responding" (ANR) dialog. Additionally, the Android UI toolkit is not thread safe.
So, you must not manipulate your UI from a worker thread—you must do all manipulation to your user
interface from the UI thread. Thus, there are simply two rules to Android's single thread model:
 Do not block the UI thread.
 Do not accesses the Android UI toolkit from outside the UI thread.

WORKER THREADS

Because of the single thread model described above, it's vital to the responsiveness of your application's
UI that you do not block the UI thread. If you have operations to perform that are not instantaneous, you
should make sure to do them in separate threads ("background" or "worker" threads).

Step1: Create a new Project (Multi Threading) with an empty activity (MainActivity).
Edit the activity_main.xml to add an ImageView and a Button which when clicked loads image to the
ImageView.

Now open the MainActivity.java

1. Create a new method to load Bitmap from the url.


2. Add an ImageView data member to the MainActivity class to point to ImageView element.
3. Now inside the onCreate method find the Button and ImageView.
4. Now implement onClick listener to the Button.
load.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
}
});

5. Now we need to create a new Thread to interact with Internet and to load the Bitmap Image.
6. Create a new thread using new Thread(Runnable runnable). The new Thread() function takes a
Runnable as argument so create a new Runnable using new Runnable.

new Thread(new Runnable() {


@Override
public void run() {
}
}).start();

7. Now we need to load the bitmap and set this bitmap to ImageView. For example we need to load
an image from url http://example.com/someUrl.jpg We could just do this by:

new Thread(new Runnable() {


@Override
public void run() {
final Bitmap bitmap = loadImage("http://example.com/someUrl.jpg");
img.setImageBitmap(bitmap);
}
}).start();

8. But this violates the rule that worker threads must not access the UI thread. However Android
Studio made some methods to let worker threads interact with UI thread.
Activity.runOnUiThread(Runnable)
View.post(Runnable)
View.postDelayed(Runnable, long

9. Here we will use the View.post() method.

10. So we are going to load an image from the link:


http://findicons.com/files/icons/820/simply_google/256/google_android.png.

11. Which is an image of the Android Robot:


load.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View v) {
new Thread(new Runnable() {
@Override
public void run() { final Bitmap bitmap =
loadImage("http://findicons.com/files/icons/820/simply_google/256/google_android.png");
//using the View.post() method to interact with UI thread
//the Bitmap is declared final since we access it inside inner class
img.post(new Runnable() {
@Override
public void run()
{ if(bitmap =null)
img.setImageBitmap(bitmap); //sets the bitmap image of ImageView
else
Toast.makeText(getApplicationContext(),
"Error in loading", Toast.LENGTH_SHORT).show();
}
});
}
}).start();
}
});

Now we need to add internet permission. Open the AndroidManifest.xml file and add
<uses-permission android:name="android.permission.INTERNET"/>

RESULT:
Thus the application that implement multithreading executed successfull
EX NO:7 DEVELOP A NATIVE APPLICATION THAT USES GPS LOCATION
INFORMATION.

AIM:

To develop a native application that uses GPS location information.

PROCEDURE:

1)Open eclipse or android studio and select new android project


2)Give project name and select next
3) Choose the android version.Choose the lowest android version(Android 2.2) and select next

4) Enter the package name.package name must be two word seprated by comma and click finish 5)Go to
package explorer in the left hand side.select our project.
6)Go to res folder and select layout.Double click the main.xml file.Add the code below

RESULT: Thus the above application executed successfully


EX NO: 8 IMPLEMENT AN APPLICATION THAT WRITES DATA
TO THE SD CARD.
AIM:
To implement an application that writes data to the SD Card.

PROCEDURE:

1. Open eclipse or android studio and select new android project

2. Give project name and select next

3. Choose the android version.Choose the lowest android version(Android 2.2) and select
next

4. Enter the package name.package name must be two word seprated by comma and click
finish
5. Go to package explorer in the left hand side.select our project.
6. Go to res folder and select layout.Double click the main.xml file.Add the code

7. Now select mainactivity.java file and type the code.

8. Next step is to set permission to write data in sd card.So go to


AndroidManifest.xml file. Copy and paste the following coding.The code should
come before <application> tab.

9. Now go to main.xml and right click .select run as option and select run configuration

10. Android output is present in the android emulator.

RESULT: Thus the Above Implement an Application That Writes Data to the Sd Card
Successfully
EX NO: 09 IMPLEMENT AN APPLICATION THAT SEND A SMS AND CREATES AN
ALERT UPON RECEIVING THE SMS

AIM:
To implement an application that creates an alert upon receiving a message in android

PROCEDURE:
1. Open eclipse or android studio and select new android project

2. Give project name and select next

3. Open eclipse or android studio and select new android project

4. Give project name and select next

5. Choose the android version.Choose the lowest android version(Android 2.2) and select
next

6. Enter the package name.package name must be two word seprated by comma and click
finish
7. Go to package explorer in the left hand side.select our project.
8. Go to res folder and select layout. Double click the main.xml file. Add the code

9. Now select mainactivity.java file and type the following code.In my coding
maniactivity name is Alert1Activity .

10. Now go to main.xml and right click .select run as option and select run configuration

11. Android output is present in the android emulator as shown in below.

RESULT: Thus implement an application that creates an alert upon receiving a message
executed
EX NO: 10 CREATE AN APPLICATION THAT MAKES USE OF MENU.

AIM:
To implement an application that creates an application that makes use of menu.

PROCEDURE:

1. Open eclipse or android studio and select new android project

2. Give project name and select next

3. Open eclipse or android studio and select new android project

4. Give project name and select next

5. Choose the android version.Choose the lowest android version(Android 2.2) and select
next

6. Enter the package name.package name must be two word seprated by comma and click
finish
7. Go to package explorer in the left hand side.select our project.
8. Go to res folder and select layout. Double click the main.xml file. Add the code

9. Now select mainactivity.java file and type the following code.In my coding
maniactivity name is Alert1Activity .

10. Now go to main.xml and right click .select run as option and select run configuration

11. Android output is present in the android emulator as shown in below.

RESULT: Thus implement an application that creates an application that makes use of menu has
been created successfully.
EXNO: 11 DEVELOP AN APPLICATION TO BUILD AN ALARM CLOCK.
.
AIM:

To develop a Android Application that creates Alarm Clock.

PROCEDURE:

Creating a New project:

 Open Android Studio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.11″ 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.

package com.example.exno11;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;

import java.util.Calendar;

public class MainActivity extends AppCompatActivity


{
TimePicker alarmTimePicker;
PendingIntent pendingIntent;
AlarmManager alarmManager;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
alarmTimePicker = (TimePicker) findViewById(R.id.timePicker);
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
}
public void OnToggleClicked(View view)
{
long time;
if (((ToggleButton) view).isChecked())
{
Toast.makeText(MainActivity.this, "ALARM ON", Toast.LENGTH_SHORT).show();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, alarmTimePicker.getCurrentHour());
calendar.set(Calendar.MINUTE, alarmTimePicker.getCurrentMinute());
Intent intent = new Intent(this, AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);

time=(calendar.getTimeInMillis()-(calendar.getTimeInMillis()%60000));
if(System.currentTimeMillis()>time)
{
if (calendar.AM_PM == 0)
time = time + (1000*60*60*12);
else
time = time + (1000*60*60*24);
}
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, time, 10000,
pendingIntent);
}
else
{
alarmManager.cancel(pendingIntent);
Toast.makeText(MainActivity.this, "ALARM OFF", Toast.LENGTH_SHORT).show();
}
}
}

RESULT:

Thus Android Application that creates Alarm Clock is developed and executed successfully.
EX NO: 12 IMPLEMENT A HYBRID MOBILE APPLICATION FOR DISPLAYING A
WEBSITE.

AIM:
To implement an hybrid mobile application for displaying a website.

PROCEDURE:

1. Open eclipse or android studio and select new android project

2. Give project name and select next

3. Open eclipse or android studio and select new android project

4. Give project name and select next

5. Choose the android version.Choose the lowest android version(Android 2.2) and select
next

6. Enter the package name.package name must be two word seprated by comma and click
finish
7. Go to package explorer in the left hand side.select our project.
8. Go to res folder and select layout. Double click the main.xml file. Add the code

9. Now select mainactivity.java file and type the following code.In my coding
maniactivity name is Alert1Activity .

10. Now go to main.xml and right click .select run as option and select run configuration

11. Android output is present in the android emulator as shown in below.

RESULT: Thus implement an hybrid mobile application for displaying a website has been
created successfully.

You might also like