You are on page 1of 61

UNIT I

INTRODUCTION TO MOBILE COMPUTING

PART-A(2 MARKS )
1) Mention some mobile computing devices?
i)laptop computers
ii) tablets
iii) smartphones
iv)E-readers
v) handheld gaming devices
2)what are the different types of networks?
Mobile computing uses different types of networks
i) wired networks
ii) wireless networks
iii) ad-hoc networks
3)what is meant by ad-hoc networks?
it is a wireless Ad-hoc network.it is a decentralized type of the wireless
network. The network is adhoc because it does not rely on a pre-existing infrastructure
such as routers in wired networks or access points in wireless networks.
4)what are the various type of wireless communication technologies used in mobiles?
There are various type of wireless communication technologies used in mobiles.
1) IrDa
2) Bluetooth
3) Wi-Fi
4) NFC
5)what do you mean by Wi-Fi?
➢ WI-Fi means wireless Fidelity
➢ Wi-FI is a technology that uses radio waves to provide network connectivity
➢ Wireless networking is known as WiFi or 802.11 networking as it covers the
IEEE 802.11 tchnologies
6)what do you mean by Wi-MAX?
WI-MAX means worldwide interoperability for microwave access. It is a type of
wireless technology that provides wireless internet service over long distance that standard
WiFi. It access the internet upto over 30 miles.
7) what do you mean by Bluetooth technology?
➢ Bluetooth is a wireless LAN technology that connects devices in a small area
➢ Compared to infrared, Bluetooth devices can work together
➢ Current devices can transfer in the range of 30 feet
➢ Blutooth uses radio frequency and hence transmission Ispossible through walls or
other objects and hence it is widely used in computers,PDA,handsets, mobile
handsets, etc
➢ These devices can communicate with each other irrespective of the manufacturer.

` PART-B (3 MARKS )
1) Briefly explain wired networks
A wired network uses physical cables, to transfer data between different devices and
computer systems . most wired networks use Ethernet cables to transfer data between
connected PCs. In a small wired networks , a single router may be used to connect al the
computers, laeger networks often involve multiple router or switches that connects to a cables
modems, telephoneline, or other type of internet connection that provides internet access to
all device connected to the network i.e. Fixed telephone networks over copper and fiber-optic
or broadband networks over DSL or cable will be part of wired network.
2) Briefly explain antennas.
an antenna is a specialized transducer that converts radio-frequency field into alternating
current or vice versa. There are two types:
1) Receiving antenna
2) Transmitting antenna
(i) Receiving antenna
It intercepts RF energy and delivers AC to electronic equipment.
(ii) Transmitting antenna
➢ It is fed with AC from electronic equipment and generates an RF field.
➢ In computer and internet wireless applications , the most common type of
antenna is the antenna is the dish antenna used for satellite communications.
➢ The disk consists of a parabolodial or spherical reflector with an active
element at its focus. When used for receiving the disk collects RF from a distant
source and focuses it at the active element. When used for transmitting the active
element radiates RF that Is collimated by the refdlctor fo delivery in a specific
direction. Active element can be a dipole antenna or horn antenna. this active
elements constitutes the main RF radiating and receiving element in dish antenna.
3) Explain any three applications of WLAN
1) In home
in homes, WLAN can be used for including networking of different home devices like
phones, computers and home appliances.
2)workgroup environment
WLAN is very useful where small workgroups or teams need to work
together. The team may be
-a survey team on top of a hill
- resce group after a natural disaster
-an accident site
-civil cinstruction sites.
3) public places
WLAN is useful in airports, railway stations or places where many people assemble
and need to access information.
4) Give any three applications of Bluetooth.
i) Wireless headsets
ii) Interface between device and entertainment systems.
iii) Replacement for some Wi-Fi networks.
iv) Wireless bridging in corporate or industrial networks.
v) Video game console controllers.

PART-C(10 MARKS )
1. Explain about important terminologies of mobile computing.

Cell
It is the smallest Geographical Area for cellular mobile communication radio coverage.
The shape of the cell is Hexagon.
Each cell has a Base Station.

Base Station
Base Station provides function between mobile unit and message switching center. Base
station consists of antenna, control unit and a transceiver. It is located in each cell.

Mobile Unit
It is a hand held device that communicates with the base station
A mobile unit is uniquely identified by International Mobile Equipment Identity (IMEI)
An individual subscriber can be identified by International Mobile Subscriber Identity.
(IMSI)

Cell Splitting
In high cellular traffic regions, the larger cells are sub-divided into smaller cells for complete
radio coverage.

Hand-off
When a mobile unit moves from one cell to another cell, the call in progress will be handed
over from one base station to another without disturbing the call in progress.

Control Channel
It is used for necessary exchange of information which is related to settings regarding
establishment of cell Base Station and the Mobile Unit.
Cell Sectoring
A single cell can be divided into multiple sectors, where the directional antenna should focus
on each sector.

Traffic Channel
It is used for carrying data or voice connections between different users.

Fading
When one signal path loses its strength, it is called Fading.

Forward Channel
The transmission of information from base station to mobile unit is called Forward Channel.
Reverse Channel
The transmission of information from mobile unit to base station is called Reverse Channel.

Transceiver
It is a device used for both transmitted and receiving radio signals.

Subscriber
Those who pays some amount as a subscription charges for using Mobile Communication
system

Mobile Station
It is present in the hand held personal unit.
It is mainly intended its service while in movement at any location.

Full Duplex System


The communication system which allows two way communications simultaneously.
Transmissions and Reception is done on two different channels.
Example : Telephone or Mobile Phone

Half Duplex System


The communication system which allows two way communications at the same channel.
Either Transmission or Reception can be done at a time.
Wireless Chord

Simplex System
The communication system which allows only one way communication
Example : Walkie Talkie

Roamer
If mobile station operated its own services from an area other than the subscribed area.

2. What are the different type of networks, mobile computing uses? Explain them.
Mobile computing uses different type of network
(i) Wired networks
(ii) Wireless networks
(iii) Ad-hoc networks
(i) Wired networks
A wired network uses physical cables, to transfer data between
different devices and computer systems . most wired networks use Ethernet
cables to transfer data between connected PCs. In a small wired networks , a
single router may be used to connect al the computers, laeger networks often
involve multiple router or switches that connects to a cables modems,
telephoneline, or other type of internet connection that provides internet access
to all device connected to the network i.e. Fixed telephone networks over
copper and fiber-optic or broadband networks over DSL or cable will be part
of wired network.
(ii) Wireless networks
Wireless network refers to the use of infrared or radio frequency signal
to share information and resources between devices.
Example for wireless devices
i) Mobile terminak
ii) Pocket size PCs
iii) Hand held PCs
iv) Laptops
v) Cellular phones
vi) PDAs
vii) Wireless sensors
viii) Satellite receivers, etc
Example for wireless networks
i) PCS(personal cellular system)
ii) AMPS(advanced mobile phone system)
iii) GSM
iv) CDMA
v) DOCOMO
vi) GPRS,etc.
iv) Ad-hoc networks
it is a wireless Ad-hoc network.it is a decentralized type of the wireless
network. The network is adhoc because it does not rely on a pre-existing
infrastructure such as routers in wired networks or access points in wireless
networks.
In latin, adhoc means for this purpose only. In these networks some of
the devices are part of the networks only for the duration of the
communication session.
In adhoc networks, new devices can be quickly added using Bluetooth
or wireless LAN . these networks don’t require subscription service, or carrier
networks.adhoc network topology is dynamic ie.., nodes enter and leave the
network continuously.
3. With neat diagram, explain the architecture of mobile computing.
the mobile computing architecture uses a three tier architecture.
3-tier architecture
This three tier architecture uses three layer.they are
(i) User interface or presentation tier(tier1)
(ii) Process management or application tier(tier2)
(iii) Database management or data tier(tier 3)

3-tier setup

presentation application Data


Web server web applica XML
Wireless Tion
internet
Ms server
NT SERVER
(html,java)

Enterprises

java ORACLE

(i) Presentation tier(tier-1)


• It is the first tier and is the user facing system.
• It is the layer of agent applications and systems.
• Generally agent software in the client device are web browsers.
• The applications run on the client device and offer all the user
interface such as session , text input,dialogue.
• This tier present information to the end user
• This tier includes web browser, and customized application
programs run by client and web server software.
(ii) Application tier(tier 2)
• The second tier is the process management or application tier
• Here business logic and rules are executed.
• It perform the business logic of processing user input, data,and
making decisions
• A middleware framework is defined as a layer of software,
which sits in the middle between the operating system and the
user facing software.
• In mobile architecture , a middle framework sits between an
agent and the business logic.
(iii) Data tier(tier 3)
• Data tier is the tier 3 in mobile architecture
• It is used to store data needed by the application and acts as a
repository for both temporary and permanent data
• Data sources can be –text file
- Flat file
- Spreadsheets
- Network database
- Relational database
- Indexed database
- Hierarchical database
- XML database
- Object database
• A legacy application can also be considered as a data source or
a document through a communication middleware.

4. Give the difference between infrared transmission and radio transmission.


INFRARED TRANSMISSION RADIO TRANSMISSION
Def Def
*Infrared light is electromagnetic radiation *radio is the transmission of signals
with a wavelength longer than that of through free space by modulation of
visible light, measured from the norminal electromagnetic waves with frequencies
edge of visible red light. below those of visible light.
Propagation Propagation
*Employed in short-range communication *radio waves travel by means of
among computer peripherals and personal oscillating electromagnetic fields that pass
digital assistant and electronic devices. through the air and the vacuum of space.
*Sender uses infrared LEDS receiver uses * information is carried by systematically
silicon photodiode to convert the infrared changing some property of the radiated
radiation to an electric current. waves such as amplitude, frequency, phase
*Responds only to the rapidly pulsing or pulse width.
signal created by the transmitter.
User
• Short range communication • Audio
• Indoor use • Telephony
• Video
• Navigation
• Radar
• Data
Advantages
• Simple circuit • Simple circuit
• Cheap • Cheap
• Lower power consumption • No licenses needed
• No licenses needed • High speed
• Higher security • Covers large area
• portable

Disadvantage
• Works only on line-of-sight mode • Limited number of free frequency
• Short range bands.
• Blocked by common materials : • Shielding is difficult.
people, walls,etc.., • Interference with other electrical
• Low bandwidth devices
• Speed is comparatively slow. • Greater power consumption
Example • Limited spectrum of frequency
• Remote control
• Mobile phones
• FM channels
• Walkie talkies
5. Explain mobile computing functions in details
1. user mobility
The User should able to use the same service from one place to another. The
service may be remote or home network.
Example: user moves from nagercoil to delhi. He uses internet to access a particular
application the same way the user uses in the home office
2. bearer mobility
It is used to same service if even if the mobile station, moves one bearer to
another bearer.
3. host mobility
In such case IP should be given care if it is on move.
4. service mobility
User change from one service to another service should remain enabled
5. network mobility
User should be able to move from one network to another network and use the
same service.
6. device mobility
User should be able to move from one device to another and use the same
service.

6.Explain the following wireless communication technology used in mobiles.


i) Bluetooth ii) Wi-Fi
(i) BLUETOOTH
• Bluetooth is a wireless LAN technology that connects device in
a small area.
• Compared to infrared, Bluetooth device can work together i.e.,
omni-directional
• Current device can transfer in the range of 30 feet.
• Bluetooth uses radio frequency and hence transmission is
possible throught walls or other objects and hence it is widely
used I computer, PDA, Headsets, Mobile hanset, etc.
• These devices can communicate with each other irrespective of
the manufacturer.
Advantages
- This device is inexpensive
- Bluetooth is sutomatic
- Low energy consumption
- Shares voice and data
Disadvantages
- Bluetooth device cannot to connected with more than one device at
a time
- Bluetooth has a low data rate in comparison to infrared

(ii) WI-FI
*Wifi means wireless fidelity
*Wifi is a technology that uses radio waves to provide network connectivity
*Wireless networking is known as wifi or 802.11 networking as it covers the IEEE
802.11 technologies.
*It range upto 50 mtrs
*It is mostly used at the speed of 7mbps and it speed is 10 times higher than Bluetooth
technology
*Which are used in wireless enabled laptops, desktop, mobiles.
*It is used in college, office, schools, conference call.
UNIT-2
INTRODUCTION TO GSM,SMS,GPRS,MOBILE OS
Part-A ( 2 MARKS)

1.What is GSM?
GSM is an abbreviation of global system for mobile communications.It is the
most widely used cellular technology in use in the world today. GSM system was
designed as a second generation (2G) cellular phone technology.
GSM offers the following services:
• Voice services
• Data services
• Short message services (SMS)

2. Define CDMA
Code Division Multiple Access (CDMA) is a digital cellular technology used for
mobile communication. It is a channel access method used by various radio
communication technologies. CDMA is an example of multiple access. Here several
transmitter can send information simultaneously over a signal communication channel.
This allows several users to share a band of frequency. To permit this without
interference between the users, CDMA uses spread spectrum technology and special
coding scheme. i.e., each transmitter is assigned a code.

3. Define SMS
SMS (Short Message Services) is commonly referred to as text messaging. It is a
service for sending short messages of upto 160 characters to mobile devices including
cellular phones, smartphones and PADs.
SMS is similar to paging. SMS message does not required the mobile phone to be
active and within range. It will be help for a number of days until the phone is active and
within range. SMS messages are transmitted within the same cell or to any one with
roaming.

4. Give two examples for VAS


i. News Service
ii. Email through SMS
iii. Chat service
iv. Health care services
5. Define GPRS.
General packet radio service (GPRS) is a packet oriented mobile data services on
the data services on the 2G and 3G cellular communication system’s global system for
mobile communication (GSM) . GPRS was originally standardized by European
telecommunications standards institute. It is now maintained by the 3rd generation
partnership project (3GPP).
GPRS usage is charged based on volume of data transferred. It is contrast with
circuit switched data, which is billed per minute of connection time.
GPRS provides data rates of 56-114 kbits/seconds.2G cellular technology
combined with GPRS is sometimes described as 2.5 G.
it provides High-speed data transfer.

6. How are GPRS application categorized ?


GPRS application are categorized as
i. Generic applications and
ii. Specific applications.

7. Mention any two features of 3G data service.


i. Video calls and video conference is also a feature in 3G mobile
technology. This reduces communication barriers between people.
ii. Online media is another exciting feature in 3G mobiles.

8. Mention any two features of 4G data services.


i. 4G technology provides very high quality audio/video over end to end internet
protocol.
ii. 4G provides very high data transfer speed of 100 Mbit/sec to 1 Gbps.

9. What do you mean by mobile operating system?


A mobile operating system is an operating system for smartphones, tablets or
other mobile devices. It combines features of a personal computer operating system with
other features useful for mobile or handheld use.

10. List any four Linux kernel based mobile Oss.


Some of the Linux kernel-based operating system used on mobile devices are
given below.
i. Android
ii. webOS
iii. FireFox OS
iv. Bada , etc..

Part-B ( 3 MARKS)

1.List the GSM entities.


GSM network id divided into four main groups. Each group contains different
entities as given below.
i. The Mobile station (MS)
Entities are
➢ Mobile Equipment (ME) and
➢ Subscriber identity module (SIM)
ii. The Base Station Subsystem (BSS)
Entities are
➢ Base transceiver Station (BTS)
➢ Base Station Controller(BSC)

iii. The Network and Switching subsystem (NSS)


Different entities are
➢ Mobile switching centre (MSC)
➢ Home location Register (HLR)
➢ Visitor Location register (VLR)
➢ Equipment identity register (EIR)
➢ Authentication center(AUC)
iv. Operation and Support Subsystem (OSS)
The entity is

➢ Operation maintenance and maintenance centre (OMC)

2. Briefly explain VAS through SMS.


Value Added Services (VAS) can be defined as services, which share one or more of the
following characteristics.
➢ Supplementary service but adds value to total service offering
➢ Stimulates incremental demand for core services offering
➢ Stands alone in terms of profitability and revenue generation potential
➢ Can sometimes stand-alone operationally
➢ Does not cannibalize basic service unless clearly favorable
➢ Can be an add-on basic service, and as such, may be sold at a premium price
➢ May provide operational and / or administrative synergy between or among other
services and not merely for diversification.

➢ Some examples
➢ News/Stock Quotes Service
➢ Session-based Chat Application
➢ Email through SMS
➢ Health Care Services
➢ Micro-payment Services

3. Explain about Generic Applications.

Generic applications are applications like information services. They are

➢ Internet access
➢ Email
➢ Web browsing
➢ Mobile commerce
➢ Banking

Generic mass market applications . they offer contents like

➢ Sports score
➢ Flight information
➢ Prayer reminders
➢ Jokes
➢ Traffic information,etc.
➢ Weather
➢ News headlines
➢ Lottery results
➢ Horoscopes

4. Explain about GPRS Specific Applications.

Chat
It is used as means to communicate and discuss matters of common interest.
GPRS will offer ubiquitous chat by integrating Internet Chat and Wireless Chat using
SMS and WAP.

2. Multimedia Services

➢ Multimedia objects like photographs, pictures postcards, greeting cards and


presentations, static web pages can be sent and received over the mobile network.
➢ It can be used for monitoring parking lots or building sites for intruders and
thieves.
➢ This can also be used by law enforcement agents, journalists and insurance agents
for sending images of accident site.

3. Virtual Private Network


➢ GPRS is used to provide VPN services.
➢ As the bandwidth is higher so many banks in India are migrating to GPRS-based
networks.
➢ This is expected to reduce the transaction time by about 25%

4. Vehicle Positioning
➢ This application integrates GPS that tell people where they are.
➢ Anyone with a GPS receiver can receive their satellite position and thereby find
out where they are.
➢ Vehicle positioning applications .

PART – C ( 10 MARKS )

1. With a neat block diagram, explain GSM Architecture.

GSM Architecture The GSM network architecture consists of three major subsystems.
They are;
➢ Mobile Station
➢ Base Station Subsystem
➢ Network Subsystem

The overall architecture of GSM


1. Mobile Station (MS):

A mobile station communicates across the air interface with a base station
transceiver in the same cell in which the mobile subscriber unit is located. The MS has
two elements. The Mobile Equipment (ME) refers to the physical device, which
comprises of transceiver, digital signal processors, and the antenna. The second element
of the MS is the GSM is the Subscriber Identity Module (SIM). The SIM card is unique to
the GSM system. It has a memory of 32 KB.

2. Base Station Subsystem (BSS):

A base station subsystem consists of a base station controller and one or more
base transceiver station. Each Base Transceiver Station defines a single cell. A cell can
have a radius of between 100m to 35km, depending on the environment. A Base Station
Controller may be connected with a BTS. It may control multiple BTS units and hence
multiple cells. There are two main architectural elements in the BSS – the Base
Transceiver Subsystem (BTS) and the Base Station Controller (BSC). The interface that
connects a BTS to a BSC is called the A-bus interface. The interface between the BSC
and the MSC is called the A interface, which is standardized within GSM.

3. Network and switching subsystem (NSS)

The NSS is responsible for the network operation. The NSS has one hardware,
Mobile switching center and four software database elements. It provides the link
between the cellular network and the Public switched telecommunicates Networks (PSTN
or ISDN or Data Networks).
The NSS controls handoffs between cells in different BSSs, authenticates user and
validates their accounts, and includes functions for enabling worldwide roaming of
mobile subscribers. In particular the switching subsystem consists of:

Mobile switch center (MSC)

It performs the switching function of the system by controlling calls to and from
other telephone and data systems. It includes functions such as network interfacing and
common channel signaling.

Home location register (HLR)

The HLR is database software that handles the management of the mobile
subscriber account. The HLR is the reference database that permanently stores data
related to subscribers, including subscriber’s service profile, location information, and
activity status.
Visitor location Register (VLR)

The VLR is temporary database software similar to the HLR identifying the
mobile subscribers visiting inside the coverage area of an MSC. The VLR assigns a
Temporary mobile subscriber Identity (TMSI) that is used to avoid using IMSI on the air.
Authentications center (Auc)

The AuC database holds different algorithms that are used for authentication and
encryptions of the mobile subscribers that verify the mobile user’s identity and ensure the
confidentiality of each call. The AuC holds the authentication and encryption keys for all
the subscribers in both the home and visitor location register.

Equipment Identity Register (EIR)

The EIR is another database that keeps the information about the identity of
mobile equipment such the International mobile Equipment Identity (IMEI) that reveals
the details about the manufacturer, country of production, and device type. This
information is used to prevent calls from being misused, to prevent unauthorized or
defective MSs, to report stolen mobile phones.
2. Explain about SMS Architecture.

SMS are basically of two types.

(i) SMMT (Short Message Mobile Terminated Point-to point)


(ii) SMMO(Short Message Mobile Originated Point-to point)

(i) SMMT
➢ SMMT is an incoming short message from the network side and is
terminated in MS.

➢ For incoming message, the path is from Sc to the MS via HLR and the
GMSC function of the home MSC.

➢ The path is SC SMS GMSC HLR MSC VLR


MSC MS2.

➢ Above diagram the message flow is indicated by the numbers in the order
as
6 7 8 9 10 11
➢ Here GMSC is a special kind of MSC. it is used to route calls outside the
mobile network.

➢ Also the term PLMN means a public land mobile network. It is any
wireless communication system intended for use by subscribers in vehicles
or on foot.
(ii) SMMO
➢ SMMO is an outgoing message original in the user device
➢ Then forwarded to the network for delivery.
➢ For out going message, the path is from MS to Sc via the VLR and the
IWMSC function of the serving MSC.
➢ The path is represented as MS1 MSC VLR MSC
SMS IWMSC SC.
➢ Above diagram the message flow is indicated by the numbers in the order
1 2 3 4 5
➢ Here IWMSC stands for interworking mobile switching centre.
➢ The serving network provides the user with access to the services of their
home environment.
➢ Home network is a type of network that facilitates communication among
devices within the close vicinity of a home.

3. Explain about GPRS Packet data Network.

GPRS technology uses packet switching in line with the internet. The makes more
efficient use of the available capacity and it allows greater commonality with internet
techniques. Here the following topics are discussed
a) Capacity and other end-user aspects
• The data transfer of GPRS is 14.4 KBps to 171.2 KBps.
• This allows comfortable internet access
• It allows e-mail, web browsing as well as large volumes of data.
• For GPRS, no dial-up modem connection is necessary.
• It is like SMS i.e. always-on services.
• Immediacy is one of the advantages of GPRS compared to circuit switched
data.

b) Quality of services(QoS)
GPRS allows definition of QoS profiles using the parameters of services
precedence, reliability, delay and throughput.
i. Service precedence
It is the priority of a service in relation to another service. There
exists three levels of priority: high, normal and low.
ii. Reliability
This indicates the transmission characteristics required by an
application.
iii. Delay
It defines maximum values for the mean delay. The delay is
defined as the end-to-end transfer time between two
communicating mobile stations or between a mobile station and the
signalling interface to an external packet data network.
iv. Throughput
It specifies maximum/peak bit rate and the mean bit rate.

c) Integral part of future 3G systems


• To reduce the delay in implementing 3G wireless systems, GPRS is
introduced.
• GPRS is an intermediate step to efficiently transport high-speed data over
the current GSM and TDMA-based wireless network infrastructures.
• Hence GPRS is called the 2.5F in the evolution process of wireless cellular
networks.

d) Goals of GPRS
• Open architecture
• Consistent IP services
• Same infrastructure for different air interfaces.
• Integrated telephony and internet infrastructure.
• Service innovation independent of infrastructure.
UNIT III

INTRODUCTION TO ANDROID

PART-A(2 MARKS)

1) What is an android?
Android is an open source and Linux based operating system for mobile device
such as smart phones and tablet computers. Android was developed by the open Handset
Alliance, led by Google and other companies

2) Mention any four android versions


The table below shows android versions, API levels and versions codes. API
levels is an integer value uniquely identified the frame work
Versions API level Versions code
Android 6,0 23 MARSHMALLOW
Android 5.1 22 LOLLIPOP_MR1
Android 5.0 21 LOLLYPOP
Android 4.4 19 KITKAT

3) List any four features of the android


SI.NO Features description
1. Beautiful UI Android OS basic screen provides a beautiful and
initiate user interface
2. Connectivity GSM/EDGE, CDMA, EV_DO, IDEN, Bluetooth,
Wi-Fi, NFC and WIMAX
3 Storage SQlite, a light weight resolution data base, is used
for data storage
4 Messaging SMS and MMS

4) What is dalvik virtual machine?


Android Runtime provides most important of android called Dalvik Virtual
Machine. Dalvik Virtual Machine is the software responsible for running apps on
android devices.

5) What is ADV?
An android virtual device is an emulator configuration that allows to develop the
test application by simulating the real device capabilities, we can configure the AVD
by specifying the hardware and the software option.
6) What is intent?
An android intent is a abstract description of an operation to be performed, intent
is an intent object. It is passive data structure which contains abstract description of an
operation to be performed.

7) What do you mean by fragment?


A fragment is a piece of an activity which enables more modular activity designe.
A fragment is a kind of the sub activity.

8) Define view
• The basic building block of user interface is a view object.
• View is a simple rectangular box which is a responsible to the user action.
• View referred to the Android.view.View class, which is the base class of all UI
classes
• Android contains the following commonly used view subclasses.
-Textview
-editText
-ImageView
-ProgressBar
-Button
-ImagesButton
-CheckBox
-DatePicker
.
9) Define ViewGroups
• Viewgroups is a subclass of the view class.
• It provides the invisible container that hold other view or viewgroup and define their
layout properties
View

Image view Text view View group

BUTTON

Liner layout Frame layou ------


10) Define notification

A notification is a message we can display to the user outside of our applications normally
UI. When we tell the system to issue a notification, it first appears as icon in the notification
area.

PART-B (3 MARKS)
1) Briefly explain android SDK

Android SDK(software development kit)

Android SDK(software development kit) is asset of development tool used to develop


application for android platform. The android ASK include the following
• Required libraries
• Debugger
• An emulator
• Relevant document for the android application program interface(API)
• Sample source code
• Tutorials for the android OS.
2) How will you create an AVD? Explain

An android virtual device is an emulator configuration that allows to develop the


test application by simulating the real device capabilities, we can configure the AVD by
specifying the hardware and the software option. AVD manager enables an each way of
creating and the managing the AVD with the graphics interface. We can create as many AVD
as we need, based on the types of device we want to test for.

Creating an AVD

In android studio window

1) Go to tools→AVD management
2) Your virtual Devices windows appear. Click Create virtual device at the left corner.
3) Many virtual devices appear. Choose phone category. select the device you want to use.
4) System image windows appear. Select the needed one and click next.
5) Verify the configuration window that appears and click finish.
6) Now nexus 5x devices emulator is included in the virtual device list.
7) Close the AVD Manager to go back to android studios main view. Now we have
configuration everything.
3) Draw the flowchart of the android fragmentation life cycle

Fragment start Fragment end

On Attach() On detach()

On create() On destroy()

On Creative() On destroy view()

On activity Created()

On start() On stop()

On resume() Fragment is On pause()


running

4) What are the types of the fragment? Explain.

i) Single frame fragments

Single frame fragments, are user in hand head devices like mobiles, here we can
show only one view.

ii) List fragment

Fragments has the special view are called list fragment.

iii) Fragment transaction


Using the fragment transaction, we can move one fragment to another fragment.
5) Explain view group
• View groups is a subclass of the view class.
• It provides the invisible container that hold other view or view group and define
their layout properties
• View group objet organize and control the layout of a screen
• It is used to creating a hierarchy of view object as in figure so that we can create
more complex layout.

6) Explain Action bar in detail

Action bar is a menu bar that runs across the top of the activity screen.
Android action bar can contain menu items which become visible when the lcicks the
‘menu’ button.

In general, an ActionBar consists of the following four components


i) App icon
App branding logo or icon will be display her.
ii) View control
A speech to display application title
iii) Action button
Some important action of the app can be added here
iv) Action overflow
All unimportant action will be shown as a menu.
PART-C (10 MARKS)

1) Write a block diagram & explain the architecture of android.

Architecture of android

The figure shows the four major layers of android operating systems. They are

(i) Application layer


(ii) Application Framework layer
(iii) Libraries and Android Runtime layer
(iv) Linux Kernel layer

(i) Application layers


• it is the topmost layer in android operating system stack.
• Here we can see the application like phone contacts, browser, etc. the android
device.
• The application we download and install from the android market and also seen
here.
• The application that we write area also located at this layer.

(ii) Application Framework layer


• It is the second topmost component in the android operating system in the
android.
• Android application directly interacts with application framework.
• Application formwork manage the basic function of the android device such a
resourse management, voice call management, etc.

Important block diagram of application framemwork are

Block Explanation
Activity This block is used to manage the computer activity life
Management cycle of application.
Content This block is used to manage the data sharing between two
Provider applications.
Telephony
Management This block is used to manage all voice calls.
Location This management is used to manage the location object
Management using GPS or cell tower.
Resource This management ids use to manage the different types of
Management resources used in android apps.

Architecture of android.

APPLICATIONS

Home Contacts Phone Browsers -- - - - - -

APPLICATION FORMWORK
Activity Window Content View
Manager Manager Provider System

Resource
Package Telephony Location Notification
Management
Management Management Management management

LIBRARIES ANDROID RUNTIME


Surface Media
SQLite
management framework Core. Libraries.

Open GL/ES Free type Webkit Dalvik Virtual Machine.

SGL SSL libc


LINUX KERNEL
Display Drive Camera Drive Flash Memory Drive Binder (IPC) Drive

Keypad Drive Wi-Fi Drive Audio Drive Power Management

(iii) Libraries and android runtime layer


• This layers has two section namely
(a) Library and
(b) Runtime

(a) Libraries
• This is present on the top of the Linux.
• It provides different libraries useful for the well functioning of android operating
system.
• Libraries are java libraries built specific for android operating system.

Some of the libraries are listed below

Libraries Explanations
SQLite It is used to access data published by content providers and includes SQLite
database management system classes.

SSL It is used to provide internet security.

OpenGL It provides java interface to the Open GL/ES 3D graphic rendering API

Media It provides different media codes which allow the recording and playback of
framework different media formats.
Webkit It is the browser engine used to display internet content or HTML content.
(b) Android Runtime
• It is placed in second layer form bottom.
• it provides most important part of android called Dalvik Virtual Machine
• Dalvik Virtual Machine is similar to JVM but only different is that it is designed and
optimized for android.
• Dalvik Virtual Machine uses code functions of Linux such as memory management
and multithreading and enable each android.

(iv) Linux Kernel Layer


• Button layer of the android operating system is the Linux kernel.
• Android is build on top of Linux 2.6 kernel and few architecture changes made by
Google.
• Linux kernel provides the basic system functionality such as process management,
memory management.
• Linux kernel also provides array of devices drives which make our while interfacing
the android with peripheral devices

2. Explain about Dalvik Virtual Machine.

Android Runtime provides most important of android called Dalvik Virtual Machine.
Dalvik Virtual Machine is the software responsible for running apps on android devices.

• It is a register based virtual machine


• It is optimized for low memory requirement.
• It is designed to allow multiple virtual memory instance to run at once
• Relies on the underlying OS for process isolation, memory management and threading
support
• It operates on .DEX files.
• DVM is build specifically for android. it is build to address the battery life, processing
power and it is free
• DVM is used instead of java Virtual Memory (JVM) is because lava and java tools are
free but JVM is no free. So the android developers from Google have made their own
virtual machine and made it as free.
• A virtual machine is necessary because the virtual machine helps in debugging as a
virtual computer. So that my applications can be run on the different devices in same
way. The figure shown is DVM.
Java*Source code

Java compiler

Java byte code DEX. Compiler

Java .virtual machines Dalvik byte code

DVM

Here java file is given to java compiler to generate .class file. All .class
file are given to dex file is given to dvm to generate final .machine code is given to CPU for
execution.

3. With Activity life cycle flow chart, explain activity in detail

Understanding activity

An activity represent a single screen with user interface just like windows or frame of
java ie. Activity per form action on the screen

EG: email applications has the following activities

i) Showing the new list of the new email


ii) Composing an email
iii) Reading the email

• If an application has more than one activity, then one of them should be marked as the
mail activities that is presented in the application is launched
• Android activity is the sub class of Context Theme Wrapper class.
• In c or c++ or java, our our program starts from the main() function. Similarly android
system initiates its program within an activity. Program starts with a class on on create() call
back method. Callback is nothing but an event.
• There is a sequence of call back method that starts up an activity.

• This activity defines the following call backs events.


S.NO Call back description
1 onCreate() Called when the activities is first created.

2 onStart called when the activity becomes visible to the user

3 onResume() Called when the users starts interactions with the application

4 onPause() Called when the current activity is been in paused and the

5 onStop() Called when the activity is no longer visible


6 onDestroy() Called to destroy the activity by the system

7 onRestart() Called when the activity restart after stopping it

• An activity is implemented as a subclass of activity class as


Public class minactivity extends activity
{
|
|
|
}
• An activity calss loads all the UI computers the XML file (Eg : activity
_main.xml) in res/layout folder of the . following statement inside onCreate()
load UI computers from res/layout/activities_main.xml file

SetContentView(R.layout.activity_main):
• Every activities we define for our application must be declare in
androidsMainfest.xml and the main activities for our app must be declare in the
manifest with an <inter_filter> that includes the MAIN action and LAUNCHER
category as folowes:

<activity android : name=”.MainActivity”>

<inter_filter>

<action android:name =”android .inter net avtion.MAIN"/>

<category android :name =”android.interner category.LANCHER”/>

<inter_filter>

</activity>

If the MAiN action or LAUNCHER category is not declare for one of our activity
,then our ap icon will not aper in the Home screen list of apps.

Here

<acticity> tag -specifies an activity

Android:name – attribute which specifies fully qualified class name of the activity
subclass.
Android.intent.action.MAIN- indicates that this activity serves as the entry point
for the application

Android.intent.category.LAUNCHER – indicates that the application can be


launched from the device,s launcher icon.

4. With fragment life cycle flowchart, explain fragments in detail.

Fragments:
A Fragment is a piece of an application's user interface or behavior that can be placed in
an Activity which enable more modular activity design. It will not be wrong if we say, a
fragment is a kind of sub-activity. Following are the important points about fragment:
➢ A fragment has its own layout and its own behavior with its own lifecycle callbacks.

➢ You can add or remove fragments in an activity while the activity is running.

➢ You can combine multiple fragments in a single activity to build a multipane UI.

➢ A fragment can be used in multiple activities.

➢ Fragment life cycle is closely related to the lifecycle of its host activity which means
when the activity is paused, all the fragments available in the activity will also be
stopped.

➢ A fragment can implement a behavior that has no user interface component.

Fragment Life Cycle Android fragments have their own life cycle very similar to
an android activity. This section briefs different stages of its life cycle.

Methods in fragment life cycle.

i) OnAttach() - by calling this method, we get a reference to the activity


which uses the fragment for further initialization work.
ii) onCreate() -creates the fragment.
iii) ocCreateView() - Fragment draes its user interface for the first time.
iv) onActivityCreated() – this method is called after onCreateView() method
when the host activity is created.
v) onStart() – Fragment gets visible.
vi) onResume() – fragment becomes active.
vii) onPause() - user leaves the fragment.
viii) osStop() - fragment is stopped.
ix) onDestroyView() - destroys fragment view.
x) onDestroy() - final cleanup opf the fragments state.
Types of fragments.

i) Single frame fragments


Frames are used in hand held devices like mobiles. here we can show only one
fragment as a view.
ii) List fragments
Fragments having special list view are called list fragments.
iii) Fragments transactions
Using with fragment transaction, we can move one fragment to another fragment.

5. Explain about listening for UI notifications.

Users interact with your UI at two levels: the activity level and the views level. At the
activity level, the Activity class exposes methods that you can override. Some common methods
that you can override in your activities include the following: .

There are two levels of android user interface with which users interact and they are.

i) Activity level
ii) View level

i) Activity level

➢ onKeyDown — Called when a key was pressed and not handled by any of
the views contained within the activity
➢ onKeyUp — Called when a key was released and not handled by any of
the views contained
➢ onMenuItemSelected — Called when a panel’s menu item has been
selected by the user
➢ onMenuOpened — Called when a panel’s menu is opened by the user
overriding methods defined in an Activity .

ii) View level

When any user interacts with a view, the corresponding view fires event. when a user
touches a button or an image button or any such view we have to service the related service so
that appropriate action can be performed.
UNIT IV
VIEWs

PART-A (2 MARKS )
1) What is view?
View is a class which represent the basic building block for user interface
components. A view occupies a rectangular area on the screen and is responsible for
drawing and event handling. View is the base class for widgets which are used to create
interactive UI component (button, ext fields, etc…,)

2) What is meant by View Group?


The View Group subclass is the base class for layouts. Layout are invisible containers
that hold other views ( or other View Groups) and define their layout properties.

3) What is the use of Text View?


Text View display text to the user and optionally allows them to edit it programmatically.
View is the parent class of Text View.
4) What is an Image Button?
Image Button displays a button with an image that can be pressed or clicked by the user.
By default , an Image Button looks like a regular button, with the standard button
background.
5) What is Toggle Button?
Android tooglebutton can be used to display checked/unchecked (on/off) state on the button.
It is useful if the user has to change the setting between two states. It can be used to on/off sound,
wifi, Bluetooth, etc.ToggleButton class is used to create the toggle button.
6) Define ProgressBar view?
Progress bars are used to show progress of a task. For example, when we are uploading or
downloading somethimg from the internet, it is better to show the progress of download/upload
to the user.
In android, there is a class called progressdialog that allows us to create progress bar. In order
to do this, we have to instantiate an object of this class.
Syntax
ProgressDialog progress = new ProgressDialog(this);
7) Define Time Picker view
Android time picker allows us to select the time of day in either 24 hours or AM/PM mode.
The time consists of hours, minute and clock format. Android provides this function through
Time Picker class.

8) Define Date Picker view


Android date picker allows us to select the date consisting of day, month and year in our user
interface. For this functionality, android provides Date Picker and DatePickerDialog
components.
9) What is the use of Image Switcher view?
Sometimes we don’t want an image to appear abruptly own the screen. But we want to apply
some kind of animation to the image when it transitions from one image to another. This
supported by android in the form of Image Switcher.
10) What is the use of Grid View?
Grid View layout is one of the most useful layouts in android. Grid View is a mainly useful
when we want to show data in grid layout like displaying images or icons. This can be used to
build application like image viewers audio or video players in order to show elements in grid
manner.
11) What are the two helper methods used for creating menus?
Before creating options and context menus, we have to create two helper methods, they are
I) First one create a list of items to show inside a menu(i.e. create menu())
II) Second one handles the event that is fired when the user selects an item
inside the menu.(i.e. Menu Choice())

12) What are the two ways to send SMS?


In android, they are two ways to send SMS. They are
i) Using device built-in application
ii) Using SMSmanager API
PART-B ( 3MARKS )

1) Briefly explain Text View


Text view display text to the user and optionally allows them to edit it
programmatically. View is the parent class of Text View

S.NO. Attributes description


1. Id It is an attribute used to uniquely identify a text
view
2. Gravity It is an optional attribute which is used to control
the alignment of the text like left, right, center, top,
bottom, center vertical, center_hoirizonal, etc
3. Text Used to set the text in a text View.
4. Text color Used to set the text color of a text view.
5. Text Size Used to set the size of a text View.
6. Text Style Used to set the text style of a text View.
7. background Used to set the background of a text View.
8. padding Used to set the padding from left, right, top or
bottom

2) Explain image button


Image button displays a button with an image that can be pressed or clicked by the user.
By default, an image button looks like a regular button, with the standard button background.
The image on the surface of the button is defined either by the android:src attribute in the
<image button> or by the setimageresource (int) method.
Attributes
Image button control attributes can be inherited from
i) Android.widget.imageview class and
ii) Android.view.view class
S.no Attributes Description
1. Android:src This defines the image on the surface of the
button.
2. Android: Crop To Padding If true, the image will be cropped to fit
within its padding.
3. Android: background This defines the background image of the
button.
4. Android:content Description This defines text that briefly describes
content of the view.
5. Android: id This supplies an identifier
6. Android: On Click This is the name of the method to invoke
when the control is clicked

7. Android: visibility This controls the initial visibility of the


control.

3) Explain Timer Picker view


Android time picker allows us to select the time of day in either 24 hours or AM/PM mode.
The time consists of hours, minute and clock format. Android provides this function through
Time Picker class.
Methods
1. Get Current Hour) – gets the current hour of the current date.
2. Get Current Minute ()-gets the current minute.
3. Is 24Hour View()- returns true if this is in 24 hours view else false.
4. Set Current Hour(integer current Hour)- sets the current hour.
5. Set Current Minute(integer current minute)-set the current minute.

4) Explain Date Picker view


Android date picker allows us to select the date consisting of day, month and year in our
user interface. For this functionality, android provides Date Picker and DatePickerDialog
components.

Methods
1) Get day of month()-gets the selected day of moth.
2) Get month()-gets the selected month.
3) Get year()-gets the selected year
4) Update date(int year, int month, int day of month)-updates the current date
5) Get calendar view()-returns calendar view
6) Get first day of week()-return first day of the week.
5) Explain List View
Android list view is a view which groups several items and display them in vertical scrollable
list. The list item are automatically inserted to the list using an adapter that pulls content from a
source such as an array of database.
An adapter actually bridge UI components and the data source that fill data into UI
component. Adapter holds the data and sends the data to adapter view. The view can take the
data from adapter view and shows the data on different views. The List View and Grid View are
subclasses of adapter view.
List view attributes

Attriburte description
Android:id This is the ID which uniquely identifies the
Android:divider view.
This is drawable or color to draw between
listitems.
Android:divideHeight This specifies height of the divide.
Android:footerDividerswEnabled Default value is true. When false, the list view
will not draw the divider after each footer
view.
Android:headerdividersenabled Default value is true. When false,the listview
will not draw the divider after each header
view.

6) Explain analog and digital view


In android, and digital clocks are usede to show time in android application. The analogclock
is a two-handed clock. Ome is hour indicator and the another one is minuteindicator.the
digitalclock looks like our normal one is minute indicator. The digitalclock looks like our normal
digital display which display hours,minutes and second in digital format. Both analogclock and
digitalclock are unable to modify the time.
The android.widget.analogclock and android.widget.digitralclock classes provide the
fumnctionality to display analog and digital clocks. Android analogclock is the subclass of view
calss.
Example
1) Create a new project
2) Drag analogclock and digitalclock from the palette into the design window
3) Include the following import statement in the MainActivity.java file.
Import android.os.bundle;
Import android.app.activity;
Import android.view.menu;
Import android.support.v7.app.AppCompatActivity;

4) Run the application. Now android emulator appears which shows current time in
analogclock as well as digitalclock

PART-C (10 MARKS )


1) Explain any three basic views with example.
Text View
Text view display text to the user and optionally allows them to edit it programmatically.
View is the parent class of Text View.

S.NO. Attributes Description


1. Id It is an attribute used to uniquely identify a text
view
2. Gravity It is an optional attribute which is used to control
the alignment of the text like left, right, center, top,
bottom, center_ vertical, center_hoirizonal, etc
3. Text Used to set the text in a text View.
4. Text color Used to set the text color of a text view.
5. Text Size Used to set the size of a text View.
6. Text Style Used to set the text style of a text View.
7. background Used to set the background of a text View.
8. padding Used to set the padding from left, right, top or
bottom

Example:
1. create a new project
2. open res-> layout->activity_main.xml file.
3. Then drag text view component and keep it inside the relative layout of the design
view.

4. TextView
android:id="@+id/text_view_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/hello" />
5. Run the project.

Edit text
Edit text is an overlay over text view that configures itself to be editable. It is
the predefined subclass of text view that includes rich editing capabilities
Attributes

S.no Attributes Description

1 Auto text Automatically correct some common spelling


errors.
2. Drawable bottom This is the drawable to be drawn below the text
3. Drawbale right This is te drawable to be drawn to the right of the
text
4. Text This is the text to display
5. Id Supplies an identifier name for this view
6. On click This is the name of the method to involve when
the view is clicked.

Button
A button is a push-button which can be pressed, or clicked by the user to
perform an action. A button consists of text or an icon that communicative what
action occurs when the user touches it.
Attributes

S.no Attributes Description

1. Auto text Automatically corrects some common spelling


errors.
2. Draw able bottom This is the draw able to be drawn below the
text.
3. Drawableright This is the draw able to be drawn to the right of
the text.
4. Text This is the text to display
5. Id Supplies an identifier name for this view
6. On click This is the name of the method to involve
when the button is clicked.
Example:

import android.app.Activity;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.widget.Button;

import android.view.View;

import android.view.View.OnClickListener;

public class MyAndroidAppActivity extends Activity {

Button button;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

addListenerOnButton();

public void addListenerOnButton() {

button = (Button) findViewById(R.id.button1);


button.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

Intent browserIntent =

new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mkyong.com"));

startActivity(browserIntent); }

});

2) Explain any three advanced view in details

Time picker view


Android time picker allows us to select the time of day in either 24 hours or AM/PM mode.
The time consists of hours, minute and clock format. Android provides this function through
Time Picker class.
Methods
1)get Current Hour() – gets the current hour of the current date.
2)get Current Minute()-gets the current minute.
3)Is 24HourView()- returns true if this is in 24 hours view else false.
4)set Current Hour(integer current Hour)- sets the current hour.
5)Set Current Minute(integer current minute)-set the current minute.
Date Picker view
Android date picker allows us to select the date consisting of day, month and year in
our user interface. For this functionality, android provides Date Picker and DatePickerDialog
components.
Methods
1) Getdayofmoth()-gets the selected day of moth.
2) Getmonth()-gets the selected month.
3) Getyear()-gets the selected year
4) Updatedate(int year, int month, int dayofmonth)-updates the current date
5) Getcalenderview()-returns calendar view
6) Getfirstdayofweek()-return first day of the week.
Analog and digital view
In android, and digital clocks are used to show time in android application. The analog clock
is a two-handed clock. One is hour indicator and the another one is minute indicator. the digital
clock looks like our normal one is minute indicator. The digital clock looks like our normal
digital display which display hours, minutes and second in digital format. Both analog clock and
digital clock are unable to modify the time.
The android.widget.analogclock and android.widget.digitalclock classes provide the
functionality to display analog and digital clocks. Android analog clock is the subclass of view
class.
Example
1) Create a new project
2) Drag analog clock and digital clock from the palette into the design window
3) Include the following import statement in the MainActivity.java file.
Import android.os.bundle;
Import android.app.activity;
Import android.view.menu;
Import android.support.v7.app.AppCompatActivity;
4) Run the application. Now android emulator appears which shows current time in
analogclock as well as digitalclock

3) Explain displaying pictures with views.


For displaying images the following views can be used
i) Imageview
ii) Galleryview
iii) ImageSwitcher
iv) Gridview

Image view
Android image view is used to display an image. To add an image to resources,
put your image into the folder “res/draw able”.
Attributes

Attribute Description
Android:croptopadding If true, the be image will be cropped to fit with its
padding
Android:MAxheight Supplies a maximum height for this view.
Android:maxwidth Supplies a maximum width for this view.
Android:scaletype Controls how the image should be resizedor moved
to match the size of this imageview
Android:src Set the drawabvle as the content of this imageview.

Methods
1) set image bitmap(bitmap bm) - sets a bitmap as the content of the image view.
2) set image Draw able (draw able draw able) - sets a draw able as the content of this image
view.
3) set image icon(icon icon) – sets the content of this image view to the specified icon.
4) setimageresource (int reside) – sets a draw able as the content of this image view
5) set image URI – set the content of this image view to the specified URI.

(ii) Gallery view


Gallery is a view used to show items in a center locked, horizontal scrolling list and user
will select a view and then user selected view will be show in the center . the items in gallery are
added using adapter.
Important methods.
1) Setanimatedduration(int) – set the duration for how lo0ng a transition animation should
run(in millisecond) when layout has changed.
2) Setspacing(int)- set the spacing between items in a gallery
3) Setunselectedalpa(float) – sets the alpha on the items that are not selected

Attributes
1) Id
2) Padding
3) Background
4) Animation duration
5) Spacing
6) Unselectesalpa, etc..,

Steps for implementation of android galleryView


1) Get the reference of gallery in class using findviewid() method.
2) Create an array of images and call the adapter usinmg gallery views object.
3) Create a custom adapter class which extends baseadapter to bind the galleryview with
a series of imageviews.

iii) imageSwitcher
sometimes we don’t want an image to appear abruptly on the screen. But we want
to apply some kind of animation to the image when it transitions from one image to
another. This is supported by android in the form of imageswitcher. An imageswitcher
allows us to add some transitions on the images through the way they appear on screen.
To use iamgeswitcher, do the following
1) define its XML component first, by dragging this control into the design view and
changing the attributes according to our need.
2) Create an instance of imageswitcher in java file and get a reference of this XML
component.

Private imageswitcher imageswitcher;

Imageswitcher=(imageswitcher)findViewBYid(R.id.imageswitcher
1);

3) Implement the viewfactory interface and implement the method that return an
iamgeview

Imageswitcher.setImageResource(R.drawable.ic_launcher);

Iamgeswitcher.setfactory(new viewFactory() {

Public view make view() {

Imageview myview = new imageview(getapplicationcontext());

Return myview;

}
4) Now add animation to the iamgeswitcher. We need to define an object of
animation class through animationUtilites class by calling a static method
loadanimation.

Animation in = animationUtils.loadAnimation(this, android.R.anim.slide_in_left);

Imageswitcher.setInanimation(in);

Imageswitcher.setOutAnimation(out);

Here the method setInAnimation sets the animation of the appearance of the object on the screen
where setOutAnimation does the opposite. The method loadanimation() creat an animation
object.
iv)gridview
gridview layout is one of the most useful layouts in android. Gridview is mainly useful
when to show data in gridlayout like displaying image or icons. This can be used to build
applications like image viewers audio or video players in order to show elements in grid manner.
Grid items are not necessarily predeterminedbut they are automatically insered to the
layout using a ListAdapter. An adapter actually bridge between UI components and the data
source that fills data into UI component.
Grid view is a subclass of adapter view and it can be populated by binding it to an
adapter. This adapter retrives data from an external source and creates a view.

4) Briefly explain sending SMS using AndroidStudio


In android, there are two ways to send SMS. They are
i) Using devices built-in application and
ii) Using SMSManager API
i) Using devices built-in application
• to activate the built-in messaging application, we can use the intent object
• this intent object should be used together with the MIMe type “vnd.android-
dir/mms-sms”
• the code for this is
Intent sendintent = new intent(intent.ACTION_VIEW);

Sendintent.setType(“vnd.android-dir/mms-sms”);

Sendintent.putExtra(“address”,”phoneno”);

Also it needs SEND_MS permission in androidManifest.xml file as


Sendintent.putExtra(“sms_body”,”messagecontent”);

StartActivity(sendintent);
<uses-permission android:name=”amdroid.permission.SEND_SMS”/>
ii) using SMS manager API
• for sending SMS message, SMS Manager class can be used.
• The code for this is

SMSManager
SMS=SMSManager.getDefault();
SMS.sendTextmessage(“phone
no”,null,”sms message”,null,null);

Here getdefault() is a static method to obtain a SMSManager object.


• For sending SMS message, sentTextMessage() method is used

• Following are the five arguments to the sendTextmessage() method.

i) Destination address- phone number of the recipient


ii) SCaddress- service center address; use null for default SMSC
iii) Text – context of the SMS message
iv) Sentintent – pending intent to invoke when the message is sent
v) Deliveryintent- pending intent to invoke when the message has been delivered.

It also needs SEND-SMS permission in androidmanifest.xml file as

<use-permission android:name= “android.permission.SEND_SMS:/>

6. Briefly exlain how to receive SMS using android studio.

For receiving SMS messages the application can be developed by using the
following classes and methods.

• SMS messages can be received by using a BroadcastReceiver object.


• The BroadcastReceiver class enables our application to receive intents sent by other
applications using the sendBroadcast() method.
• The SMS message is contained in the intent object.
• The messages will be stored in the PDU format.
• To extract each mesasage,we can use CreateFrompdu() method from the
SMSMessage class.
• The SMS message is then displayed using the Toast class.
• The phone number if the sender is obtained via the get Originating Address()
method.

i) <uses-permission
android:name=”android.permission.RECEIVE_SMS”/>

ii) <receiver android:name=”.receivername”><intent-filter>

• We can continue to listen for coming SMS messages even if the application is not
running as long as the application is installed on the device.
• In the Androidmanifest.xml file,we have to include the folllowing.

<action android:name = “android.provider.telephony.SMS_RECEIVED”/>

</intent-filter>

</receiver>
UNIT V

LOCATION BASED SERVICE AND SQLITE

PART A(2 MARKS)

1.Define location based service.

Location based services are services offered through a mobile phone and take into
account the devices geographical location. one of the key ingredients in a LBS app is maps.
this presents a visual representation of our location.

2. What are the two methods used for zoom control?

There are two methods used for zoom control.

(i) Using built-in zoom controls.


(ii) Programmatically zooming in or out of the map.

3. What is meant by geo coding?

In location based service if we know the address of a location but want to know its
latitude and longitude, the process used for this is known as geo coding. For geo coding,
the class used is Geocoder. And the methods used are

Get from location name()

Get Latitude()

Get Longitude()

4. What is meant by reverse geocoding?

In location based service if we know the latitude and longitude of a location, we can
find out its address. the process used for this purpose is called as reverse geocoding.
Google maps in android supports this via the Geocoder class.

5. Define content provider.

A content provider is a component that supplies data from one application to others on
request. a content provider can use different ways to store its data and the data can be
stored in a database, in files or even over a network.

6.Define android service.

An android service is a component that runs in the background to perform long


running operations without needing to interact with the user and it works even if
application is destroyed. a service can take two states.
They are

(i) started

(ii) bound

7. What are the two methods used for sending data using HTTP protocol?

Android app uses HTTP protocol to send data. The methods used for sending data are

(i) GET method


(ii) POST method

8. Define web service.

Web service is a platform independent, language independent consumable service


using HTTP over the internet developed to perform a certain task.

Eg: to get the current weather.

Apps on your phone like Whatsapp, Facebook, Gmail uses web services.

PART B (3 MARKS)

1. Briefly explain zoom control.


For permitting the users to zoom in or out of the map on the android emulator,
there are two methods available, they are
(i) Using built-in zoom controls.
(ii) Programmatically zooming in or out of the map.

(i) Using built-in zoom controls


➢ To display the built-in zoom controls,
➢ We have to first get a reference to the map.
The call the set built in zoom controls () method as follows:

Mapview=(mapview)findviewbyid(R.id.mapView);

Mapview.setBuiltinzoomcontrolIs (true);

When running the application with the above code, a map appears. When we click and
drag the map, built-in zoom controls appear at the bottom of the map.

We can click the minus(-) icon to zoom out of the map and the plus(+) icon to zoom into the
map.

(ii) Programmatically zooming in or out of the map.


To manage the zooming of the map ,we have to obtain an instance of the
MapController class from the MapView object.

The mapController class contains the Zoomin() and zoomOut() methods to enable
users to zoom in or out of the map respectively.

2. Explain downloading binary data.


For downloading binary data follow the steps given under the previous heading

‘Requests and Responses in Android Http client’

Downloading Text Content

For downloading text content from the internet,use the following


procedures.

1 Create HTTP Client

HttpClient httpclient=new defaultHttpClient( );

2) Set the action you want to do.

HttpGet httpget=new httpGet(http://yoururl.com);

3) Execute it.

HttpResponse response = httpclient.execute(httpget);

HttpEntity entity= response.getEntity();

4) create an Inputstreamwith the response

InputStream is = entity.getcontent();

5) create buffer for reading


BufferedReader reader= new BufferedReader (new
InputStreamReader(is,’’iso-8859-1’’),8);

6) create a string builder.

StringBuilder sb= new StringBuilder();

String line = null;


7) Read line by line

While((line= reader.readLine())!=null)

Sb.append(line + “\n”);

8) form the result.

String resString = sb.toString();

9) close the stream.

Is.close();

10) also don’t forget to use android.permission.INTERNET in


androidmanifest.xml.file

3. Explain accessing web service

The following tasks are needed to access data from the web service.
(I) Using HTTP, client is connected to the server.
(II) If HTTP POST method is used for sending requests to the server, the HttpPost
class is used to specify the URL of the server. The data are accessed and appended to
the URL.
(III) T he Http Client class is used to connect to the server.
(IV) The Http Response class is used to get the connection status from the server. If
the status code is 200,it means that the connection is successfully established with the
server.
(V) On establishing connection with the server, the Buffer Reader and Input Stream
Reader classes are used to fetch the information returned by the web service. The
information returned by the service is in JSON format.
(VI) From the received JSON format the data are accessed and displayed.
(VII) Also to access the web service uploaded on a server, we need to add internet
permission in the AndroidManifest.xml file as
<uses-permission android:name = “android.permission.INTERNET”/>

PART C (10 MARKS)

1. Explain about adding markers in android.

Adding markers to a map indicates places of interest.it enables users to easily locate
the places they are looking for. the procedure to add a marker to google maps is given below.

1).create a GIF image containing a pushpin.copy it into the res/drawable_mdpi folder


of the project.for the best effect,make the background of the image transparent so that it does
not block parts of the map when the image is added to the map.

2).to add marker to the map,we first need to define a class that extends the overlay
class.

Class MapOverlay extends

Com.google.android.maps.Overlay

@ override

Public Boolean draw(---)

//--

An overly represents an individual item that we can draw on the map.we can add as many
overlays as we want.

3).in the mapoverlay class,override the draw() method so that we can draw the
pushpin image on the map.

4).next we have to translate geographical location represented by geopoint object(for


eg.say p)into screen coordinates.

Point screenpts=new Point();

Mapview.getProjection().toPixels(P,screenpts);
5).because we want the pointed tip of the pushpin to indicate the position of the
location,we need to deduct the height of the image(for eg.say50pixels) from the y coordinate
of the point(see the figure below)and draw the image at that location.

Bitmap bmp=BitmapFactory.decodeResource(getResources(),R.drawable.pushpin);

Canvas.draw.Bitmap(bmp.ScreenPts.x,ScreenPts.y-50,null);

6).to add the marker,create an instance of the MapOverlay class and add it to the
list of overlays available on the MapView object.

MapOverlay mapoverlay=new MapOverlay();

List<Overlay>listofOverlays=mapView.getoverlays();

Listof Overlays.clear();

ListofOverlays.add(mapOverlay);

2. Explain about Storing and retrieving datas in internal storage

Storing and retrieving datas in internal storage.

We can save files directly on the device’s internal storage.by default,files saved to
the internal storage are private to our application and other applications cannot access
them.when the user uninstalls the application,these files are removed.

a).storing datas in internal storage

to careate and store a private file to the internal storage,

1).call OpenFileOutput() with the name of the file and the operating mode.this returns a
FileoutputStream.

2).write to the file with write().

3).close the stream with close().

Example:

FILENAME=”welcome_file”;

String string=” String Welcome you all”;

FileOutputStream fos=”openFileOutput(FILENNAME,Context.MODE_PRIVATE);

Fos.write(String.getBytes());
Fos.close();

Here MODE_PRIVATE will create the file and make it private to our
application.other modes available are MODE_APPEND,MODE_WORLD_READABLE and
MODE_WORLD_WRITABLE.

b).Reading from internal storage

1).call openFileinput() and pass it the name of the file to rea.this returns a FileinputStream.

2).read bytes from the file with read().

3).then close the stream with close().

3. explain about Storing and retrieving datas in external storage

Every android-compatible device supports a shared “external storage” that we can


to save files.this can be a removable storage media(such as an SD card) or an internal(non-
removable)storage.files saved to the external storage are world-readable and can be modified
by the user when they enable USB mass storage to transfer files on a computer.

External storage can become unavailable if the user mounts the external storage
on a computer or removes the media,and there’s no security enforced upon files we save to
the external storage.all applications can read and write files placed on the external storage
and the user can remove them.

a).storing datas in external storage

for storing files on the external storage,our app must acquire


WRITE_EXTERNAL_STORAGE system permission.

For example,

<manifest….>

<uses-permission
android:name=”android.permission.WRITE_EXTERNAL_STORAGE”/>

</manifest>

The steps for storing public file to the external file name.

Storage are

1).create FileOutputStream with the external file name.

2).write to the file with write().


3).close the stream with close().

b).reading from external storage

for reading files from the external storage,our app must acquire
READ_EXTERNLA_STORAGE system permission.for example,

<manifest….>

<uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE”/>

</manifest>

The steps for reading are

1).create FileinputStream with external file name.

2).create DatainputStream using FimeinputStream pointer.

3).create Inputstreamreader using datainputstream.

4).create bufferedreader using inputstreamreader.

5).read lines from the buffer with readline() method.

6).finally close the stream datainputstream and fileinputstream.

4. How will you create and use databases using Sqlite.

SQLite

It is a opensource SQL database that stores data to a text file on a device.Android


comes in with built in SQLite database implementation.

Creating database

In order to create a database, we just need to call this method openOrCreateDatabase with our
database name and mode as a parameter.it returns an instance of SQLite database which we
have to receive in our own objects.

Syntax

SQLiteDatabase mydatabase=openOrCreateDatabase

(‘’your databasename”,MODE_PRIVATE,null);
Using databases

a) Database insertion

We can create table or insert data into table using execSQL method defined in
SQLiteDtatabase class.
Mydatabase.execSQL(“CREATE TABLE IF NOT EXISTS polytechnic(username
VARCHAR,password VARCHAR);”);

SQL(“INSERT INTO polytechnic VALUES (‘admin’,’admin’);”);

b) Data base updation


It inserts data as well as updates or modifies already existing data in database
using bind arguments.

Syntax

execSQL(string sql,object[]bindArgs)
c) Database fetching

We can retrieve anything from database using an object of the Cursor class.
We will call a method of this class called raw query and it will return a with the
cursor pointing to the table. we can move the cursor forward and retrieve the data.

Ex:

Cursor resultset = mydatabase.rawQuery

(“select *from polytechnic”,null);

resultSet.moveToFirst();

String username= resultSet.getString(0);

String password= resultSet.getString(1);

You might also like