Application Developmen Lab 1
Application Developmen Lab 1
LAB MANUAL
191CSC611L
APPLICATION DEVELOPMENT LABORATORY (MOBILE/WEB)
Prepared By Approved by
0 0 3 1 2
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.
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:
REFERENCES:
MINI PROJECTS
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
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:
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;
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:
PROCEDURE:
PROGRAM:
Activity_main.xml:
<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;
@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 ) {
});
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.
paint.setColor(Color.BLUE);
SET THE STROKE WIDTH:
paint.setStrokeWidth(0);
DRAW A RECTANGLE:
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:
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
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:
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.
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.
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:
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
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:
PROCEDURE:
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
PROCEDURE:
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
9. Now go to main.xml and right click .select run as option and select run configuration
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
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
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:
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
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:
PROCEDURE:
Open Android Studio and then click on File -> New -> New project.
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;
@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:
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
RESULT: Thus implement an hybrid mobile application for displaying a website has been
created successfully.