Smart Devices13
Smart Devices13
STUDENTS VERSION
PROGRAM OUTCOMES
Rough record and Fair record are needed to record the experiments conducted in
the laboratory. Rough records are needed to be certified immediately on completion of
the experiment. Fair records are due at the beginning of the next lab period. Fair
records must be submitted as neat, legible, and complete.
In the fair record, the index page should be filled properly by writing the corresponding
experiment number, experiment name , date on which it was done and the page
number.
1. Title: The title of the experiment should be written in the page in capital letters.
2.Exp No: And Date: In the top margin, experiment number and date should be written.
7. Results: The results of the experiment must be summarized in writing and should be
fulfilling the aim.
SAFETY PROCEDURES
Problem Statement:
The safety instructions are presented to the attention of the students as a mean of
preventing accidents while performing experiments and activities in Software lab
of the department .The purpose is to draw attention to the risks involved in lab
activities to prevent human suffering and damage to equipment.
Inform the lab in charge about dangerous conditions and faults in the lab or nearby
environment.
Do not do any action that may harm people or equipment in the lab.
At the end and beginning of laboratory, follow 5S procedures and leave the work
table clean and tidy.
Electrical Safety:
Consult Electrical Engineering section available in the campus for electrical safety
queries.
Department of Computer Engineering, GPTC Perumbavoor 7
The lab equipment is powered from electrical sockets installed on the tables.
Do not use equipment that is powered from flexible cable with damaged insulation
or if it’s plug is not assembled properly.
Do not open the main fuse box, unless it is an emergency and you need to switch
off main circuit breaker.
Be sure to turn off the power and remove the power plug from all equipment
before working repairing or assembling.
Emergency Switches:
The laboratory has circuit breakers, which is located in the main panel. Identify the
place.
Result:
Readiness to do experiment
Completion of Experiment
Android is a software package and Linux based operating system for mobile devices such as
tablet computers and smartphones. It is developed by Google and later the OHA (Open Handset
Alliance). It's a consortium of 84 companies such as google, samsung, AKM, synaptics, KDDI,
Garmin, Teleca, Ebay, Intel etc.It was established on 5th November, 2007, led by Google. It is
committed to advance open standards, provide services and deploy handsets using the Android
Plateform.Java language is mainly used to write the android code even though other languages
can be used. The goal of android project is to create a successful real-world product that
improves the mobile experience for end users.There are many code names of android such as
Lollipop, Kitkat,Jelly Bean, Ice cream Sandwich, Froyo, Ecliar, Donut etc
An android component is simply a piece of code that has a well defined life cycle e.g. Activity,
Receiver, Service etc. The core building blocks or fundamental components of android are
activities, views, intents, services, content providers, fragments and AndroidManifest.xml.
Activity-An activity is a class that represents a single screen. It is like a Frame in AWT.
View-A view is the UI element such as button, label, text field etc. Anything that you see
is a view.
Intent-Intent is used to invoke components.
Service-Service is a background process that can run for a long time. There are two
types of services local and remote. Local service is accessed from within the application
whereas remote service is accessed remotely from other applications running on the
same device.
Content Provider-Content Providers are used to share data between the applications.
Fragment-Fragments are like parts of activity. An activity can display one or more
fragments on the screen at the same time.
Android Emulator
Android Emulator is used to run, debug and test the android application. If you don't have the
real device, it can be the best way to run, debug and test the application. It uses an open source
processor emulator technology called QEMU. The emulator tool enables you to start the
emulator from the command line.
OUTPUT
RESULT
With the advancement of smart phones in the recent years, Android has become one of the
biggest phone platforms and all the tools required to build Android applications are also freely
available. Android Studio is an Integrated Development Environment (IDE) for developing
Android applications. Installation on Ubuntu 15.04 We can install Android Studio in two ways.
The first method is to set up the required repository and install it,
The second method is to download it from the official Android site and install it locally.
In the first method, we will be setting up the repo using command line and install it. Before
proceeding, we need to make sure that we have JDK version1.6 or greater installed.
Step4: $ /opt/android-studio/bin/studio.sh
Step5:Click Next->Next. Once you press the Finish button, Licence agreement will be displayed.
After you accept the licence, it starts downloading the required components.
Android studio installation will be complete after this step. When you relaunch Android studio,
you will be shown the following welcome screen from where you will be able to start working
with your Android Studio.
OUTPUT
RESULT
Android Studio is one of the best and most popular IDE for development of Android
application which is released by IntelliJ IDEA. Android studio has rich functionalists and easy to
work. Android studio has great and awesome user interface, it is also smart with coding and
will save time. To download Android Studio, it is need to visit official site of android. There will
be android studio download button. After downloading android studio, follow below steps to
install android studio on your computer.
Step1: Open you downloaded android studio file and wait for few seconds, it will take some
time to load on your screen.
Step2: After that the window will appear on your screen, where it will show you welcome to
android studio. Go for "Next"
Step3: Now choose what you want to install, all are most important component in android
programming. Go for "Next"
Step4: Go for "I Agree", It's for integrating SDK, it will confirm SDK installation.
Step6: Now choose the location for Android Studio and SDK. Go for "Next"
Step7: Here we need to define the size of android emulator processor. We can define up to
2GB and more than that, depends on your RAM capacity. The size will be determined through
Haxm. This will help android studio to run faster.
Step8: Now choose setting for shortcut of android studio on your computer.
Step9: After that it will take lots of time to copy all the files to the storage location you have
selected before.
RESULT
1. In the Welcome to Android Studio window, click Start a new Android Studio project. or if
you have a project opened, select File > New Project.
2. In the Create New Project window, enter the following values:
Application Name: "My First App"
Company Domain: "example.com"
You might want to change the project location. Also, if you want to write a Kotlin app, check
the Include Kotlin support checkbox. Leave the other options as they are.
3.Click Next.
4.In the Target Android Devices screen, keep the default values and click Next.
5.In the Add an Activity to Mobile screen, select Empty Activity and click Next.
6.In the Configure Activity screen, keep the default values and click Finish.
1.In Android Studio, click the app module in the Project window and then select Run > Run
2.In the Select Deployment Target window, click Create New Virtual Device.
3.In the Select Hardware screen, select a phone device, such as Pixel, and then click Next.
5.Click Next.
6.On the Android Virtual Device (AVD) screen, leave all the settings alone and click Finish.
7.Back in the Select Deployment Target dialog, select the device you just created and click OK.
Android Studio installs the app on the emulator and starts it,"Hello World!" displayed in the app
running on the emulator.
OUTPUT
RESULT
AIM:
PROCEDURE
1. In Android studio, create new project.
2. Fill out the fields on the screen and click Next.
3. Click next and select blank activity and the click Next.
4. Under the Customize the Activity, change the Activity Name and Layout Name.
5. Click the Finish button to create the project
6. Run the app on emulator by choosing an android virtual device.
PROGRAM
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
AIM:
THEORY
Android Toast can be used to display information for the short period of time. A toast contains
message to be displayed quickly and disappears after sometime.
Method Description
PROCEDURE
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
AIM:
THEORY
Activity is one of the building blocks of Android OS. In simple words Activity is a screen that user
interact with. Every Activity in android has lifecycle like created, started, resumed, paused,
stopped or destroyed. These different states are known as Activity Lifecycle. Android Activity
Lifecycle is controlled by 7 methods of android.app.Activity class.
onStart() – Called just after it’s creation or by restart method after onStop(). Here Activity start
becoming visible to user
onResume() – Called when Activity is visible to user and user can interact with it
onPause() – Called when Activity content is not visible because user resume previous activity
onStop()–Called when activity is not visible to user because some other activity takes place of it
onRestart() – Called when user comes on screen or resume the activity which was stopped
PROCEDURE
SOURCE CODE
MainActivity.java
Department of Computer Engineering, GPTC Perumbavoor 21
/**********Write the java code*****************/
Activity_main.xml
OUTPUT
RESULT
THEORY
The EditText is the standard text entry widget in Android apps. If the user needs to enter text
into an app, this is the primary way for them to do that. Getting the value of the text entered
into an EditText is as follows:
EditText simpleEditText = (EditText) findViewById(R.id.et_simple);
String strValue = simpleEditText.getText().toString();
PROCEDURE
1. Create a new Android Project
3. Create two EditText instances and a button by declaring it inside XML file
4. In java file
a. Create objects of Button and TextField class
b. Set a click listener on the button object
c. Retrieve the values from two TextFields.
d. Specify the addition operation inside onClick() method
e. Invoke show() method of Toast class to display the sum.
5. Execute the application by clicking the menu Run -> Run
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
AIM
THEORY
Android Toggle Button can be used to display checked/unchecked (On/Off) state on the
button.It is beneficial if user have to change the setting between two states. It can be used
to On/Off Sound, Wifi, Bluetooth etc.
XML Attribute
PROCEDURE
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
UNDERSTANDING CHECKBOX
AIM:
THEORY
Methods
PROCEDURE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
AIM:
To familiarize attributes and methods of Radio Button and Radio Group class.
THEORY
PROCEDURE
Activity_main.xml
OUTPUT
RESULT
EXPLICIT INTENT-I
AIM:
THEORY
Android application components can connect to other Android applications. This connection is
based on a task description represented by an Intent object. Intents allow you to interact with
components from the same applications as well as with components contributed by other
applications. Explicit intents explicitly define the component which should be called by the
Android system, by using the Java class as identifier.The following shows how to create an
explicit intent and send it to the Android system to start an activity.
PROCEDURE
Click the app folder for your project and choose File > New > Activity >
Empty Activity.
Name the new activity "SecondActivity." Check Generate Layout File
and layout name will be filled in as activity_second.
Click Finish.
Open manifests/AndroidManifest.xml.
Find the <activity> element that Android Studio created for the second
activity. <activity android:name=".SecondActivity"></activity>
Add these attributes to the <activity> element: android:label= "Second
Activity" & android:parentActivityName= ".MainActivity".
5. Define the layout for the second activity
Open res/layout/activity_second.xml and change the root view group to
RelativeLayout
Add a TextView and set attribute text as “Second Activity”.
6. Add an intent to the main activity
Open the Java file for MainActivity
Create a new intent in the launchSecondActivity() method.
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
AIM:
To understand passing of selected radiobutton and EditText value to another activity using
Intent.
THEORY
Explicit intents explicitly define the component which should be called by the Android system, by using
the Java class as identifier. The following code is to create an explicit intent and send it to the Android
system to start an activity.
PROCEDURE
1.Start Android Studio and create a new Android Studio project.
Click the app folder for your project and choose File > New > Activity >
Empty Activity.
Name the new activity "SecondActivity." Check Generate Layout File
and layout name will be filled in as activity_second.
Click Finish.
Open manifests/AndroidManifest.xml.
Find the <activity> element that Android Studio created for the second
activity. <activity android:name=".SecondActivity"></activity>
Add these attributes to the <activity> element: android:label= "Second
Activity" & android:parentActivityName= ".MainActivity".
6.Modify the second activity to get the extras and display the message
Open java/com.example.android.twoactivities/SecondActivity.
In the onCreate() method, get the intent that activated this activity: using
getIntent();
Get the string containing the message from the intent extras using
getStringExtra().
Set the message to TextView.
SOURCE CODE
MainActivity.java
Activity_main.xml
SAMPLE OUTPUT
RESULT
AIM:
To understand passing data of selected Checkbox and EditText value to another activity using
Intent.
THEORY
Explicit intents explicitly define the component which should be called by the Android system, by
using the Java class as identifier. The following code is to create an explicit intent and send it to
the Android system to start an activity.
The selection of checkbox can be check with the method isChecked() and text can be retrieved
by getText().
PROCEDURE
Click the app folder for your project and choose File > New > Activity >
Empty Activity.
Name the new activity "SecondActivity." Check Generate Layout File
and layout name will be filled in as activity_second.
Click Finish.
Open manifests/AndroidManifest.xml.
Find the <activity> element that Android Studio created for the second
activity. <activity android:name=".SecondActivity"></activity>
Add these attributes to the <activity> element: android:label= "Second
Activity" & android:parentActivityName= ".MainActivity".
4. Define the layout for the second activity
Open res/layout/activity_second.xml and change the root view group to
RelativeLayout
Add two TextViews.
5. Add an intent to the main activity
Open the Java file for MainActivity
Retreive the value from selected checkboxes using isChecked() and
getText().
Create a new intent in the launchSecondActivity() method.
Send data from the main activity to the second activity using putExtra()
method.
Call the startActivity() method with the new intent as the argument.
6. Modify the second activity to get the extras and display the message
Open java/com.example.android.twoactivities/SecondActivity.
In the onCreate() method, get the intent that activated this activity: using
getIntent();
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
RESET BUTTON
AIM
To understand retrieve value from EditText and set value to the TextView on same activity.
THEORY
EditText is a subclass of TextView with text editing operations. We often use EditText in our
applications in order to provide an input or text field, especially in forms.getText() method to
get the text entered in the EditText views. But getText()method returns an Editable instance
and therefore we have typecasted it to convert it into String for further use. This can be done
by using the toString() method.
In Android, TextView displays text to the user and optionally allows them to edit it
programmatically. TextView code in JAVA:
PROCEDURE
In java file
Create objects of Button ,EditText and TextView class
Set a click listener on the submit button object
Retrieve the values from two EditText.
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
AIM:
THEORY
Android provides Built-in applications for phone calls, in some occasions we may need to make
a phone call through our application. This could easily be done by using implicit Intent with
appropriate actions. Also, we can use PhoneStateListener and TelephonyManager classes, in
order to monitor the changes in some telephony states on the device. ACTION_CALL action
trigger built-in phone call functionality available in Android device. Following is simple syntax
to create an intent with ACTION_CALL action
ACTION_DIAL action can be used instead of ACTION_CALL, in that case we will have option to
modify hardcoded phone number before making a call instead of making a direct call.To make
a phone call at a given number 91-000-000-0000, we need to specify tel: as URI using setData()
method as follows −
phoneIntent.setData(Uri.parse("tel:91-000-000-0000"));
To make a phone call, Android need CALL_PHONE permission .In Manifest.xml file add this
1.Open Android Studio and start create a new project with an empty activity called MainActivity
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
STUDENT DATABASE
AIM:
To learn how to insert, up, delete and retrieve records in SQLite Database in Android
THEORY
SQLite is used as a database for android application development. SQLite is a Structure query
base database, open source, light weight, no network access and standalone database. SQLite
is RDBMS (Relational Database Management System), is written in C programming
language.SQLite is embedded within the Android operating System, no need of anything
external on Android to use SQLite.To manipulate data (insert, up , delete) in SQLite database
– we’ll use SQL (Structured Query Language)
PROCEDURE
5. In Main Activity.java
SOURCE CODE
MainActivity.java
Activity_main.xml
OUTPUT
RESULT
*
**
***
****
*****
2. Implement different layouts in Android Studio.
3. Create an activity to accept details of a student such as Roll No and Name. Toast the
details on same activity.
4. Create an activity to accept two numbers. Toast the sum on same activity.
5. Create an activity to accept details of a student such as Roll No and Name. Display the
details on another activity.
6. Create an activity to input details of a student such as Roll No, Name and branch should
be selected from ( Mech, EC & Computer). Toast the details on same activity.
7. Create an activity to choose your favourite books. Toast the details on another activity.
8. Create a simple List View
9. Create a simple List View with image and text
10. Integrate a website inside the application using Webview
11. Create an employee database and prepare pay bill.
*************************************************************************