UNIT I- GETTING STARTED WITH MOBILITY
MOBILITY LANDSCAPE
Today, mobility is one of the most desirable characteristics by customers for many
applications or systems like online shopping, online service facilities, managing money through
online transactions, watching movies.
Smart phones or mobile phones are preferable medium to do such kind of transactions
with high mobility.
Mobility refers transforming user experience from the confines of a desk to the convenience of
anytime–anywhere. This mobility panorama can be broadly classified into logical landscape and
physical ecosystem.
Logical landscape
It describes the rationale behind mobility for different stakeholders. Logical landscape defines
two logical components of mobility
Consumer mobility is focused toward the end user, and typically comprises domestic
mobility solutions such as social networking, games, shopping, bidding, and utilities.
Enterprise mobility is focused toward various stakeholders of an organization such as
vendors, partners, suppliers, workforce, and their end customers. Enterprises across
industry segments are leveraging the mobility channel to extend their reach and simplify
business processes to cater to more and more customers, and in turn, increase profits. It
also increases productivity of their mobile workforce.
Physical ecosystem
It describes about physical ecosystem portrays the infrastructure that enables mobility. There are
three key distinct physical components – mobility components, enterprise components, and
middleware and protocols that glue the first two components.
Mobility components are mobile devices, which is the centerpiece of mobility, in
varieties of shapes and sizes. Mobile platforms are software stacks that power mobile
devices. Mobile app stores are online distribution systems
Middleware and Protocols which acts as a glue between mobility and enterprise
components. Access mechanisms such as Wi-Fi, Bluetooth, CDMA, GPRS, and GSM
are some of the key components of this layer. WAP and SMS gateways for interaction
Enterprise components which refers hosts of servers, such as database servers and
application servers, that cater to enterprise portion of mobility solutions. It cater to the
requirements of data security, data synchronization between mobile devices and servers.
MOBILE PLATFORMS
Mobile platform is not just an operating system, but a software stack that typically
comprises an operating system, libraries, and application development framework. It is a suite of
software tools used for designing, creating and maintaining mobile applications. This platform
also provides testing applications, measuring mobile analytics and creating interfaces for
profiling application performance
An operating system, core features are memory management, process management, and
various device drivers
Libraries – furnish media libraries that provide codecs, libraries for native data storage,
libraries for rendering screens and drawing surfaces, and libraries for graphics
Application development framework(s) - the set of Application Programming
Interfaces (APIs) that in turn interact with the underlying libraries, and are exposed to the
developers for app development
Example: Android, IOS windows
APP DEVELOPMENT APPROACHES
The development of mobile app is driven by three key aspects
1. First aspect is the business use case that the app is going to mobilize. It can be
o Business-to-Consumer (B2C) scenario such as delivering in-store offers on
customers devices in a retail outlet or facilitating banking on consumers’ devices.
o Business-to-Employee (B2E) scenario such as providing guided sales facilities on
sales workforce devices through smart devices for medical practitioners
o Business-to-Business (B2B) scenario such as mobilizing supply chain
management of an enterprise and respective vendors/partners/supplier
2. Second aspect is the profile of the user who is going to use the app. The user may be a
field
agent, customer, partner, executive, or a member of senior management
3. Last one is mobile device that plays the app. The device type, device connectivity
(offline/online), and the operating environment play keyrole
These 3 factors determine the app development requirements with respect to
user experience
device diversity
offline capabilities
security, backend integration,
app life cycle management, etc
There are three broad approaches to develop a mobile app, namely native, web, and hybrid
Native approach yields a native app that is developed for the native platform by using
platform specific APIs. This approach is used primarily when the app requires a native look and
feel; and needs to leverage high-end device capabilities.
Web approach it is typically developed using web technologies such as HTML5, CSS3,
and JavaScript. A web app is not installed on a mobile device; it rather gets rendered in a
mobile browser, over the network. The web approach is used primarily when the app requires to
cater to diverse devices using a single codebase.
The hybrid approach is a mixed approach that incorporates features of both native and
web approaches while developing an app. Apps in hybrid approach are implemented using
mobile cross platforms. Unlike mobile native platforms, these platforms do not power a mobile
device. These platforms are device agnostic and facilitate multiplatform development, wherein
the same codebase of a mobile app can be translated to fit into any of the supported native
platforms. These platforms follow three broad philosophies to build apps using hybrid approach:
Web-based philosophy: Using web-based philosophy, a hybrid app is created in two steps. The
first step creates a web app using the usual web approach and second step wraps
the web app with a native wrapper. A native wrapper enables the app to leverage the underlying
hardware features in a device.
Cross-compiler philosophy: Using cross-compiler philosophy, a hybrid app is created using
web technologies, and the resultant app can be cross compiled for the supported mobile native
platforms
Middleware philosophy: A pure middleware philosophy enables a hybrid app to be hosted on a
middleware server. Users can retrieve the app from middleware as and when required, while the
middleware server will facilitate the interaction between the app and the enterprise systems at the
backend.
Setting up Development Environment
Android primarily uses Java for development. Java Development Kit (JDK) is required for
developing Java applications. Besides the JDK, we require
Android Software Development Kit (SDK)
Eclipse Integrated Development Environment (IDE) or Android Studio
Android Development Tools (ADT) plugin
By default, the SDK consists of only the latest version of Android. The Android SDK
Manager comes handy to update the existing SDK.
It is recommended to use an IDE for quick, efficient, and professional development of apps.
Eclipse is one of the preferred IDEs for Android apps development. But today, it is advised to
use Android studio framework which provides all sort of tools for developers.
ADT plugins provides various functionalities which can be incorporated into our mobile
applications and these plugins are available in Android official website.
Android Architecture
The Android OS is built on top of a modified Linux kernel. The software stack contains Java
applications running on top of a virtual machine. Components of the system are written in Java,
C, C++, and XML. Android operating system is a stack of software components which is
roughly divided into five sections 1) Linux kernel
2) Native libraries (middleware),
3) Android Runtime
4) Application Framework
5) Applications
Linux kernel
It is the heart of android architecture that exists at the root of android architecture. Linux kernel
is responsible for device drivers, power management, memory management, device management
and resource access. This layer is the foundation of the Android Platform.
Contains all low level drivers for various hardware components support.
Android Runtime relies on Linux Kernel for core system services like, Memory, process
management, threading etc
Network stack
Driver model
Security and more
Libraries
On top of Linux kernel there is a set of libraries including open-source Web browser engine
WebKit, well known library libc, SQLite database which is a useful repository for storage and
sharing of application data, libraries to play and record audio and video, SSL libraries
responsible for Internet security etc. SQLite Library used for data storage and light in terms of
mobile memory footprints and task execution.
WebKit Library mainly provides Web Browsing engine and a lot more related features
The surface manager library is responsible for rendering windows and drawing surfaces
of various apps on the screen.
The media framework library provides media codecs for audio and video.
The OpenGl (Open Graphics Library) and SGL(Scalable Graphics Library) are the
graphics libraries for 3D and 2D rendering, respectively.
The FreeType Library is used for rendering fonts
3) Android Runtime
In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application. DVM is like JVM but it is optimized for mobile devices.
It consumes less memory and provides fast performance. The Dalvik VM makes use of Linux
core features like memory management and multi-threading, which is intrinsic in the Java
language. The Dalvik VM enables every Android application to run in its own process, with its
own instance of the Dalvik virtual machine.
Android Framework
On the top of Native libraries and android runtime, there is android framework. Android
framework includes Android API's such as UI (User Interface), telephony, resources, locations,
Content Providers (data) and package managers. It provides a lot of classes and interfaces for
android application development.
• Activity Manager: manages the life cycle of an applications and maintains the back stack as
well so that the applications running on different processes has smooth navigations.
• Package Manager: keeps track of which applications are installed in your device.
• Window Manager : Manages windows which are java programming abstractions on top of
lower level surfaces provided by surface manager.
• Telephony Managers: manages the API which is use to build the phone applications Dalvik is
a specialized virtual machine designed specifically for Android and optimized for battery-
powered mobile devices with limited memory and CPU. Android apps execute on Dalvik VM, a
“clean-room”
implementation of JVM Dalvik optimized for efficient execution
Dalvik: register-based VM, unlike Oracle’s stack-based
JVM Java .class bytecode translated to Dalvik EXecutable (DEX)
bytecode, which Dalvik interprets
• Content Providers: Provide feature where one application can share the data with another
application. like phone number , address, etc • View Manager : Buttons , Edit text , all the
building blocks of UI, event dispatching etc.
Applications
• On the top of android framework, there are applications. All applications such as home,
contact, settings, games, browsers are using android framework that uses android runtime and
libraries. Android runtime and native libraries are using linux kernel. Any applications that you
write are located at this layer.
Creating fist app
In Eclipse, Right click on the Package Explorer window of the Eclipse workbench. Click on
New. A set of options such as Java Project and Android Application Project appears to select
from.
1. A New Android Application wizard appears, to capture details such as Application
Name, Project Name, and Package Name. Besides this, select other details such as
Minimum Required SDK, Target SDK, Compile With, and Theme of the application.
2. Click on Next to open Configure Project screen. Select Create custom launcher icon
checkbox to help create an app icon that the end user will see on the device after
installing the app. Select Create activity checkbox to create an Activity – a component
that defines the user interface (UI) of an app.
3. Click on Next. The Configure Launcher Icon screen, which allows us to choose and
configure the app icon
4. Click on Next. The Create Activity screen appears that allows us to select the kind of
launcher Activity to be created
5. The New Blank Activity screen, appears that allows us to provide details for creating a
blank Activity. Provide the Activity Name, and the Layout Name of the layout file to be
created
6. Click on Finish, and that is it! Here is our first app!
Setting up an Emulator
An emulator is typically a software that virtually reproduces the exact behavior of one
computing machine on another. AVD (Android Virtual Devicer) runs on Microsoft Windows,
and reproduces an Android mobile device’s behavior such as placing or receiving calls, sending
SMS, and launching a mobile app.
To set up an emulator, click on Yes in the Android AVD error dialog window. It opens
the AVD Manager dialog window. Now, to create a new AVD, click on New option in the AVD
Manager. This will open up the Create new AVD dialog window, as depicted in Fig. 2.14, with
options to create and configure an AVD.
We can now launch the newly created emulator by selecting it, and clicking Start. This will bring
up a screen resembling a real mobile device. However, let us not use the AVD Manager dialog
window to start the emulator.
Behind the scene
When the FirstApp project is executed by selecting Run As → Android Application, a
.apk (Android package) file gets created through a series of implicit steps.
The Java source code gets compiled into ‟.class” files, which in turn get converted into a
single ‟.dex” file. The dx tool, which is part of the Android SDK, performs this conversion. A
.dex file is an executable file that runs inside the Dalvik Virtual Machine (DVM) when the app is
launched. This file is packaged along with app resources and manifest file to yield a .apk file
using Android Application Packaging Tool.
During the runtime of an app, the Android platform initiates a process that in turn
contains an instance of DVM to host the app. Each app that is running on the device/emulator
has a dedicated process and a DVM in which it gets executed. This runtime architecture ensures
the robustness of the platform by making sure that if one app behaves erratically, it does not
affect other running apps.
Android Project Structure
Every Android app project is organized into a structure with varieties of artifacts such as
the source code, image resources, string resources, menus, screen definitions, media files, and
app configuration files.
1. FirstApp is the name of the project.
2. src is the source folder where all .java files are placed. Android mandates the creation of
packages to manage the .java files. A package name must have at least two identifiers, for
example, com.mad.
3. MainActivity is the default launcher activity of the app It inherits from the Activity class and
contains the onCreate() method. Within this method, the setContentView() method is called to
inflate the layout of the screen.
4. R.java is an autogenerated file containing integer constants for all resources included in the
project. The integer constants defined here will be used in other java files to refer to different
resources using the format R.<folder_name>.<res_name>, as seen in Line 9 of Snippet 2.1.
5. ic_launcher.png is the default icon of the app. It is placed under the res\drawable-hdpi folder.
The res folder contains all the app resources. The drawable subfolder in it is a container for all
image resources. Several drawable subfolders (drawable-hdpi, drawable-ldpi, drawable-mdpi,
and drawable-xhdpi) are included in a project to manage duplicate image resources of varying
dimensions. This is done to ensure that image resources appear best across all possible screen
densities.
6. activity_main.xml is a layout resource that defines the blueprint of various elements
appearing on the screen of the app. This file can be edited to modify the look and feel.
7. main.xml ( under the menu folder contains the definition of a menu in the app
8. strings.xml contains string resources in a key–value pair format or an individual UI element
in it.
9. AndroidManifest.xml is the most important file in an Android app. It is a registry of several
details such as list of the logical components, sdk requirements, and version of the app etc.
Logical Components of Mobile App
There are the logical Components which constitutes various basic functionalities to our mobile
applications.
Activity: It is the basis of the UI of any Android app. The overall UI may consist of other visual
elements, layout elements, resources. Simply say, an activity refers the screen of mobile app
Service: Service is another key logical component of an Android app which runs in the
background, and does not have an UI. To interact with a Service, typically an UI (Activity) is
associated with it.
Broadcast Receiver: While the mobile device is being used, there may be several
announcements (broadcasts) which an app needs to capture and respond to. The may be call, an
incoming SMS, availability of Wi-Fi spot, or low battery etc… The component that captures and
responds to such announcements is called as Broadcast Receiver.
Content Provider: Persisting data pertaining to an app and making it accessible across apps is a
crucial aspect of mobile app development. An app needs to share the data with other apps, the
data has to be exposed, which is done using Content Provider.
Mobile Application Challenges
User experience–specific challenges
Short span of user focus
Native look and feel
Responsiveness
Personalization
App functionality–specific challenges
Battery life and computational power
Network access
Data-specific challenges
Security
Privacy
Platform-specific challenges
Platform fragmentation
Screen types
Input mechanisms
To create a winning app we have to design it in such a way that it always enjoys advocacy
from end users. This may be achieved by following five tenets: The app should be intimate,
interactive, immediate, intelligent, and insightful.
******************