Ch1 Android and Its Tools
Ch1 Android and Its Tools
Learning Objectives…
▣ To understand Basic Concepts in Mobile Application Development and Android
▣ To learn Android with its Need, Features etc.
▣ To study Android Architecture
▣ To learn Tools in Android and Development of Android Application
1.0 INTRODUCTION
• A mobile application, most commonly referred to as an app, is a type of application software
designed to run on a mobile device, such as a smart phone or tablet computer.
• Mobile app development is the process by which a mobile application is developed for mobile devices
like Personal Digital Assistants (PDAs), tablet computer or mobile smart phones.
• Android is a mobile operating system developed by Google, based on a modified version of the Linux
kernel and other open source software and designed primarily for touchscreen mobile devices such
as smart phones and tablets.
• Today, Android is arguably the world’s most popular platform for mobile devices. Android brings
Google and the whole internet to users of smart phones, tablets and other mobile devices. In the
process, it is changing how we communicate with one another.
• For application developers, Android is an open platform that provides exciting opportunities for
developing virtually any app imaginable. With a user base that continues growing every day,
Android also has a built-in open marketplace for distributing new apps.
• Android applications can be packaged easily and sold out either through a store such as Google Play,
Windows Phone Store, SlideME, Opera Mobile Store, Mobango, F-droid and the Amazon Appstore.
[1.1]
Mobile Application Development 1.2 Android and its Tools
• Android was unveiled during 2007 along with the founding of the Open Handset Alliance (OHA).
• A mobile app is a program designed to run on smart phones, tablet computers and other mobile
devices.
• Developing mobile applications for Android platform will give us access to a large and expanding
market in a wide variety of devices.
Handset
Manufactures
Mobile Chip
Operators Makers
Open Handset
Alliance
(OHA)
Software Commercializaton
Companies Companies
Consumers
OEMs
2. Connectivity: On one page/desktop we could be able to have four connecting device tool button
like, Turn ON/OFF Bluetooth, Turn ON/OFF WiFi, Turn ON/OFF mobile network, Turn On/Off
GPS and so on. These buttons let us switch ON/OFF instantly which will help us to conserve
battery life.
3. Browser: The Android OS browser is one of the best browsers on the mobile market. It generally
loads pages faster than Safari or any other browser, has Flash support and simply does
everything a browser should do. For example, iPhone has Safari browser. It is stable, has no Flash
support, so we cannot watch Youtube videos or any related contents, it is not flexible but
monopolistic.
4. Open to Carrier: If we know Java programming language then we are open to Android world.
5. Market: Android OS has an android market. The android apps are free and work as well.
6. Future: The future mobile phones are basically going to be smart phones.
7. Muti-Notification: Android phones have multi-notification system. With android the app have
access to the notification system and call all report.
8. Google Integration: The Android has inbuilt google support. For examle, Google Map, G-Mail etc.
9. Open Source: The code of android OS as well as the apps is available.
10. Endless Personalization: The Android cell phone allows to configuration their mobile to look and
behave exactly like they want.
Android 2.2 On May 20, 2010, the SDK for 1. Speed up of the application
Froyo Android 2.2 (Froyo, short for performance due to JIT compiler.
frozen yogurt) was released, 2. Support for the Android Cloud to
based on Linux kernel 2.6.32. Device Messaging (C2DM) service.
3. Improved Microsoft Exchange
support, including security policies,
auto-discovery etc.
4. Supports USB tethering and Wi-Fi
hotspot functionality.
5. Support for installing applications to
the expandable memory (memory
card).
6. Support for high-PPI displays (up to
320 ppi), such as four-inch 720p
screens.
7. Quick switching between multiple
keyboard languages and their
dictionaries.
4. Android 2.3/2.4 On December 6, 2010, the 1. Faster, more intuitive text input in
Gingerbread Android 2.3 (Gingerbread) SDK virtual keyboard, with improved
was released, based on Linux accuracy, better suggested text and
kernel 2.6.35. voice input mode.
2. Support for extra-large screen sizes
and resolutions (WXGA and higher).
3. support for VoIP (Voice over
Internet Protocol) internet
telephony.
4. Updated user interface design with
increased simplicity and speed.
5. Support for Near Field
Communication (NFC), allowing the
user to read an NFC tag embedded in
a poster, sticker, or advertisement.
6. Support for multiple cameras on the
device.
7. Support for voice or video chat using
Google Talk.
5. Android On February 22, 2011, the Android 1. Optimized tablet support with a new
3.0/3.1/3.2 3.0 (Honeycomb) SDK – the first “holographic” user interface.
Honeycomb tablet-only Android update – was 2. Added System Bar, featuring quick
released, based on Linux kernel access to notifications, status, and
[81][82][83][84]
2.6.36. The first device soft navigation buttons, available at
featuring this version, the the bottom of the screen.
Motorola Xoom tablet, was 3. Multiple browser tabs replacing
released on February 24, 2011. browser windows, plus form auto-fill
Mobile Application Development 1.7 Android and its Tools
External storage
Media support
Streaming Media
Support
Voice based
features
Multitouch
Web Browser
Video Calling
Accessibility Multitasking
Fig. 1.4
• Android is an open source, lightweight and powerful operating system which supports great
features. Few features of them are listed below:
1. Storage: SQLite, a lightweight relational database, is used for data storage purposes.
2. Multitasking: Multitasking of application, with unique handling of memory allocation, will be
existing.
3. Web Browser: The web browser available in Android OS is based on the open-source WebKit
layout engine, attached with Chrome’s V8 JavaScript engine. The browser scores 100/100 on top
of the Acid3 test on Android 4.0.
Mobile Application Development 1.13 Android and its Tools
4. Open Source: Android is open-source operating system. The source code for Android is open to
the public, dissimilar iOS, which is kept secret by Apple. This way that anyone can work on the
operating system, not only one company developers. Therefore app developers for android
devices are able to implement extra features of their apps, due to the access they have to contain
the source code.
Again these are only some of the unique features to Android. iOS also have many key abilities
that are missing on android devices. In the end it is up to we to decide which operating system
you would rather have. Anyone of you choose will be the right decision for you.
5. Accessibility: Built in text to speech in Android OS is provided by Talk back for people with low
or no vision. Enhancements for people through hearing disabilities are available as is other aids.
6. Media Support: Android supports the following audio/video/still media formats: WenM,H.263,
H.264, AAC, HE-AAC, MPEG-4 SP, AMR, AMR-WB, MP3, MIDI, WAV, JPEG, PNG, GIF, OggVorbis,
FLAC, BMP, WebP
7. Streaming Media Support: Android OS support RTP/RTSP streaming, HTML progressive
download. Adobe Flash Straming (RTMP) and HTTP Dynamic Streaming are supported by the
Flash plugin. Apple HTTP Live Streaming is support through RealPlayer for Android, and through
the operating system for the duration Android 3.0(Honeycomb).
8. Voice Based Features: Google search through voice has been available since Android operating
system release. Voice activities for navigation, calling, texting etc. are supported on android 2.2
forwards. As of Android 4.1, Google has expanded Voice actions with the ability to talk back and
read answers from Google’s Knowledge Graph when queried with specific commands. The ability
to control hardware have not yet been implemented.
9. Multitouch: Android OS have native support for multitouch which was initially made available
in handsets such as HTC Hero. These features was originally disabled at the kernel level. Google
has released an update version for Nexus One and Motorola Droid which enables multi-touch
natively.
10. External Storage: Number of Android devices include microSD slot and can rea microSD cards
formatted with FAT32, Ext3 or Ext4 file system. To allow use of high-capacity storage media such
as USB flash drives and USB HDDs, many Android tablets also include USB ‘A’ receptacle. Storage
format with FAT32 is handled by Linux Kernel VFAT driver. As 3rd party solutions are necessary
to handle other popular file systems such as NTFS, HFS Plus and ex FAT.
11. Video Calling: Video calling through Google Talk is available within Android 2.3.4 and later.
Gingerbread allows Nexus S to place Internet calls with a SIP account. This allows for enhanced
VoIP dialing to other SIP accounts and even phone numbers. Skype 2.1 offer video calling in
android 2.3, include front camera support, Users with the Google+ Android app can video chat
with other Google+ users through hangouts.
12. Handset Layout: The Android OS is adaptable to the size of the display device. The graphical
rendering of individual screens is done by the 2D/3D library based on OpenGL ES 2.0
specifications and traditional of smart phones.
13. GCM: Google Cloud Messaging (GCM) is a service that lets developers send short message data to
their users on Android devices, without needing a proprietary sync solution.
14. Wi-Fi Direct: A technology that lets apps discover and pair directly, over a high-bandwidth peer-
to-peer connection.
• The Android SDK is compatible with Windows, Mac and Linux operating systems to build android
applications based on our requirements.
• We can setup android development environment using following two ways:
• Setup Eclipse IDE Manually (Depreciated) and
2. Android Studio
• Initially Google supported a Manual Eclipse IDE Setup for android development environment by
downloading required components like Eclipse IDE, Android SDK, Java Development Kit (JDK) etc.
from official site. Afterwards Google introduced a component called Android Studio to make
environment setup process simple.
• By using Android Studio bundle we can easily setup android development environment in any
operating system to implement android applications.
• Android Studio is the combination of following components to allow users to implement android
applications.
• Eclipse IDE, Android SDK, Android Virtual Device, and Eclipse Plugin
• By downloading Android Studio directly from Google website to setup we can easily setup
development environment.
• Check following steps to know more details about setting up android development environment to
implement required apps using Android Studio.
Download Android Studio:
• In this section we are going to explain how to install android studio on windows machine which is
having Windows 10 operating system.
• Download the latest version of Android Studio from above URL and launch Android Studio.exe file by
double clicking on it.
• The initial android studio setup screen will open like as shown below in that click Next to continue
for further steps of environment setup, (See Fig. 1.5).
• Now we need to select a required components to setup an android environment. Here we selected all
three components (Android Studio, Android SDK and Android Virtual Device) and click Next like as
shown below.
• Now we need to agree the License agreements to proceed further, click on I Agree button like a
shown below.
• Now we need to specify the local machine drive location to install Android Studio and Android SDK.
After selecting the location path to install required components, click Next like as shown below.
Mobile Application Development 1.15 Android and its Tools
• Now select the start menu folder to create a shortcuts for android studio and click Install like as
shown below.
• Once we click Install button the installation process will start and click Next after completion of
installation like as shown below.
• After that it will show installation completion wizard in that click Finish to launch android studio
like as shown below.
Mobile Application Development 1.16 Android and its Tools
• While launching Android Studio it will give you an option to import settings from previous version
of studio. In case if you don’t have any previous version, select second option and click OK like as
shown below.
• Now android studio will open a welcome wizard window in that click Next to validate our current
Android SDK and development environment setup like as shown below.
• Now select a Standard installation type and click Next to install a common settings and options like
as shown below.
• Now verify settings and click Finish to complete android studio setup process like as shown below.
Fig. 1.16
Fig. 1.15
• After completion of required components installation click on Finish like as shown below.
• After completion of all required components installation we will be able to see Android Studio
welcome window like as shown below.
Mobile Application Development 1.17 Android and its Tools
-
Fig. 1.17
• This is how we can setup android development environment on windows machine which is having
windows 10 operating system using android studio IDE.
• Fig. 1.18 shows the following various layers that make up the Android Operating System (OS).
1. Applications:
• The top layer of android architecture is Applications. The native and third party applications like
Contacts, Email, Music, Gallery, Clock, Games, etc. whatever we will build those will be installed on
this layer only.
• The application layer runs within the Android run time using the classes and services made available
from the application framework.
2. Application Framework:
• The Application Framework provides the classes used to create an Android application. It also
provides a generic abstraction for hardware access and manages the user interface and application
resources.
• It basically provides the services through which we can create the particular class and make that
class helpful for the Applications creation.
• The application framework includes services like telephony service, location services, notification
manager, NFC service, view system, etc. which we can use for application development as per our
requirements.
3. Android Runtime:
• Android Runtime environment is an important part of Android rather than an internal part and it
contains a components like core libraries and the Dalvik virtual machine.
• The Android run time is the engine that powers our applications along with the libraries and it forms
the basis for the application framework.
(i) Dalvik Virtual Machine (DVM) is a register-based virtual machine like Java Virtual Machine (JVM).
It is specially designed and optimized for android to ensure that a device can run multiple
instances efficiently. It relies on the Linux kernel for threading and low-level memory
management.
(ii) The core libraries in android runtime will enable us to implement an android applications using
standard JAVA programming language.
4. Platform Libraries:
• The Platform Libraries includes various C/C++ core libraries and Java based libraries such as SSL,
libc, Graphics, SQLite, Webkit, Media, Surface Manger, OpenGL etc. to provide a support for android
development.
• Following are the summary details of some core android libraries available for android development.
• Media library for playing and recording an audio and video formats
(i) The Surface manager library to provide a display management
(ii) SGL and OpenGL Graphics libraries for 2D and 3D graphics
(iii) SQLite is for database support and FreeType for font support
(iv) Web-Kit for web browser support and SSL for Internet security.
5. Linux Kernel:
• Linux Kernel is a bottom layer and heart of the android architecture. It is heart of Android
architecture that exists at the root of android architecture and contains all the low-level device
drivers fro the various hardware components of an Android device.
• Linux Kernel is responsible fro device drivers, power management, memory management, device
management and resource access. It manage all the drivers such as display drivers, camera drivers,
Bluetooth drivers, audio drivers, memory drivers, etc. which are mainly required for the android
device during the runtime.
• The Linux Kernel will provides an abstraction layer between the device hardware and the remainder
of the stack. It is responsible for memory management, power management, device management,
resource access, etc.
Mobile Application Development 1.19 Android and its Tools
• Practice Questions
Android (Hello World) Example
• Android Studio is the official Integrated Development Environment (IDE) for Android app
development, based onIntelliJ IDEA .
• Android Studio offers even more features that enhance your productivity when building Android
apps, such as:
1. A fast and feature-rich emulator.
2. User friendly IDE.
3. A flexible Gradle-based build system.
4. A unified environment where we can develop for all Android devices.
5. Instant Run to push changes to the running app without building a new APK.
6. Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging
and App Engine
• The first step is to create a simple Android Application using Android studio. When we click on
Android studio icon, it will show screen as shown in Fig. 1.19
Fig. 1.20
Fig. 1.19
• We can start our application development by calling Start a new Android Studio project. In a new
installation frame should ask Application name, package information and location of the project.
(See Fig. 1.20)
• After entered application name, it going to be called select the form factors our application runs on,
here need to specify Minimum SDK, in we have declared as API23: Android 6.0(Mashmallow),
(See Fig. 1.21)
Mobile Application Development 1.20 Android and its Tools
Fig. 1.21
• The next level of installation should contain selecting the activity to mobile, it specifies the default
layout for Applications (See Fig. 1.22).
Fig. 1.22
• At the final stage it going to be open development tool to write the application code.
Mobile Application Development 1.21 Android and its Tools
Fig. 1.23
Anatomy of Android Application:
• Before we run our app, we should be aware of a few directories and files in the Android project,
(See Fig. 1.24).
Fig. 1.24
• The description of Fig. 1.24 is:
Sr. No. Folder, File & Description
1. Java
This contains the .java source files for your project. By default, it includes an
Mobile Application Development 1.22 Android and its Tools
MainActivity.java source file having an activity class that runs when your app is launched
using the app icon.
2. res/drawable-hdpi
This is a directory for drawable objects that are designed for high-density screens.
3. res/layout
This is a directory for files that define your app's user interface.
4. res/values
This is a directory for other various XML files that contain a collection of resources, such as
strings and colours definitions.
5. AndroidManifest.xml
This is the manifest file which describes the fundamental characteristics of the app and
defines each of its components.
6. Build.gradle
This is an auto generated file which contains compileSdkVersion, buildToolsVersion,
applicationId, minSdkVersion, targetSdkVersion, versionCode and versionName
• Following section will give a brief overview of the important application files.
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
• Here <application>...</application> tags enclosed the components related to the application.
Attribute android:icon will point to the application icon available under res/drawable-hdpi. The
application uses the image named ic_launcher.png located in the drawable folders
• The <activity> tag is used to specify an activity and android:name attribute specifies the fully
qualified class name of the Activity subclass and the android:label attributes specifies a string to use
as the label for the activity. You can specify multiple activities using <activity> tags.
• The action for the intent filter is named android.intent.action.MAIN to indicate that this activity
serves as the entry point for the application. The category for the intent-filter is named
android.intent.category.LAUNCHER to indicate that the application can be launched from the
device's launcher icon.
• The @string refers to the strings.xml file explained below. Hence, @string/app_name refers to the
app_name string defined in the strings.xml file, which is "HelloWorld". Similar way, other strings get
populated in the application.
• Following is the list of tags which you will use in your manifest file to specify different Android
application components:
1. <activity>elements for activities
2. <service> elements for services
3. <receiver> elements for broadcast receivers
4. <provider> elements for content providers
Android - Application Components:
• Application components are the essential building blocks of an Android application. These
components are loosely coupled by the application manifest file AndroidManifest.xml that describes
each component of the application and how they interact.
• There are following four main components that can be used within an Android application −
1. Activities: They dictate the UI and handle the user interaction to the smart phone screen.
2. Services: They handle background processing associated with an application.
3. Broadcast Receivers: They handle communication between Android OS and applications.
4. Content Providers: They handle data and database management issues.
• There are additional components which will be used in the construction of above mentioned entities,
their logic, and wiring between them. These components are:
1. Fragments: Represents a portion of user interface in an Activity.
Mobile Application Development 1.24 Android and its Tools
2. Views: UI elements that are drawn on-screen including buttons, lists forms etc.
3. Layouts: View hierarchies that control screen format and appearance of the views.
4. Intents: Messages wiring components together.
5. Resources: External elements, such as strings, constants and drawable pictures.
6. Manifest: Configuration file for the application.
Strings File:
• The strings.xml file is located in the res/values folder and it contains all the text that our application
uses. For example, the names of buttons, labels, default text, and similar types of strings go into this
file. This file is responsible for their textual content. For example, a default strings file will look like
as following file:
<resources>
<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>
Layout File:
• The activity_main.xml is a layout file available in res/layout directory, that is referenced by your
application when building its interface. You will modify this file very frequently to change the
layout of your application. For your "Hello World!" application, this file will have following content
related to default layout −
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
• This is an example of simple RelativeLayout which we will study in a separate chapter. The TextView
is an Android control used to build the GUI and it have various attributes like android:layout_width,
android:layout_height etc which are being used to set its width and height etc.. The @string refers to
the strings.xml file located in the res/values folder. Hence, @string/hello_world refers to the hello
string defined in the strings.xml file, which is "Hello World!".
Running the Application
• Let's try to run our Hello World! application we just created. We assume we had created our AVD
while doing environment set-up. To run the app from Android studio, open one of our project's
activity files and click Run icon from the tool bar.
• Android studio installs the app on your AVD and starts it and if everything is fine with our set-up
and application, it will display following Emulator window:
Mobile Application Development 1.25 Android and its Tools
Fig. 1.25
Advantages Android:
1. Supports 2D, 3D graphics: It supports various platforms like 2D and 3D. Earlier we used to watch
movies and play games in almost in 2D, but nowadays various applications are using 3D format.
To provide different graphics in videos, games OS should support 3D format. Android supports
2D and 3D format to provide a better advantage in videos and in games.
2. Supports Multiple Languages: Android supports different languages. We can say all famous
languages about more than 100. By using this feature it is easy to adopt to different languages.
Earlier in the feature phones English is to be the only language in the mobile devices.
3. Faster Web Browser: As it enabled with web browser we surf web easily without complexity just
like in a computer. It easily loads multimedia so that it makes web browsing faster.
4. Video Calling: Faster data connection enables to do video call. We can take advantage of
bandwidth and new generation networks using Android.
5. Open Source Framework: It makes users to make their own applications and to make changes
required for themselves. Enthusiasts can make Andriod more powerful and useful by developing
themselves. As it is an open source operating system, we can use it easily and without cost in the
equipments.
6. Uses of Tools are Very Simple: It makes use of a single button to do more than assigned work.
For example volume control button can be made to click a photo by changing simple algorithm in
the android.
7. Availability of Apps: Anyone can make use lot of free apps in the app store and from other
android stores. It gives freedom to install from third party users.
8. Great Social Networking Integration: Integration can be made to different social networking
sites,so you can enhance features. Free to customize the applications and features, using user
enabled development
9. Better Notification System: It makes users to check important notifications directly from the
dashboard. It makes work easy. Earlier we used to go for every application refresh to check
updates.
10. Updated User Interface Design: Interfacing that means human to machine integration made to
update in android. Touchscreen made very useful change in the mobile use. It enables zooming
and tapping features which perform very effectively in the Android operating system
11. At a Time Aplications: Can run numerous applications which allow consumers to help save time
and efforts
Mobile Application Development 1.26 Android and its Tools
12. Low Chance of Crashing: The Android OS is very smooth and easy to operate and less chances of
crashing down
13. Stability: Stability and security is better than other mobiles OS as it is based on Linux Kernel. The
Linux based operating system enabled with high security with unix. Every operation goes into
command mode. If detected any security threats it goes to basic mode by storing to another
application like cloud computing and crashes all the data on the device.
14. Multitasking: Android phones can run many applications, it means we can browse while
listened to the song.
Disadvantages Android:
1. Need internet connection: Android requires an active internet connection. At least there should
be a GPRS internet connection in your area, so that the device is ready to go online according to
our needs.
2. Advertising: Application in the Android phones can indeed be obtained easily and for free, but
the consequences in each of these applications, will always be ads on display, either the top or
bottom of the application.
3. Wasteful Battery: Android more wasteful than any other operating system, because this
operating system is a lot of "process" in the background that lead to the battery quickly drains.
4. Many applications contain virus: The virus inserted android applications including Counter
Strike Ground Force, Puzzle Sexy Girls, Sexy Girls Photo Game, etc. Android Application contain
virus also present in the Android Market.
5. Slow response: compared to ‘ios’ of apple,windows 8 of Microsoft.when we open same app in the
ios and windoes8. We observe the slow response of the android when we open apps in the
different platforms.
6. Heat: Compared to other operating systems android makes use of processes very efficient. This
makes processor to get heat. Some hardware companies take care to reduce heat,but it went in
vain when we operate it a long time and at low battery.