Android Unit 1
Android Unit 1
Unit 1
Overview of Android
What is Android?
• Android is an open-source operating system based on Linux with a Java programming interface
for mobile devices such as Smartphone (Touch Screen Devices who supports Android OS) as
well for Tablets too.
• Android was developed by the Open Handset Alliance (OHA), which is led by Google. The Open
Handset Alliance (OHA) is a consortium of multiple companies like Samsung, Sony, Intel and
many more to provide services and deploy handsets using the android platform.
• In 2007, Google released a first beta version of the Android Software Development Kit (SDK)
and the first commercial version of Android 1.0 (with name Alpha), was released in September
2008.
• In 2012, Google released another version of android, 4.1 Jelly Bean. It’s an incremental update
and it improved a lot in terms of the user interface, functionality, and performance.
• In 2014, Google announced another Latest Version, 5.0 Lollipop. In Lollipop version Google
completely revamped the UI by using Material Designs, which is good for the User Interface as
well for the themes related.
• All the source code for Android is available free on Git-Hub, Stack overflow, and many more
websites. Google publishes most of the code under the Apache License version 2.0.
Android Features
This is a powerful open-source operating system which provides a lot of great features, those are
Feature Description
Beautiful UI Android OS basic screen provides a beautiful and intuitive user interface.
Feature Description
Connectivity GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and WiMAX.
Storage SQLite, a lightweight relational database, is used for data storage purposes
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3, MIDI, Ogg
Media support
Vorbis, WAV, JPEG, PNG, GIF, and BMP
Google Cloud Messaging (GCM) is a service that let developers send short message
GCM
data to their users on Android devices, without needing a proprietary sync solution.
A technology that let apps discover and pair directly, over a high-bandwidth peer-to-
Wi-Fi Direct
peer connection.
Android History
Initially, Google launched the first version of Android platform on Nov 5, 2007, from that onwards
Google released a lot of android versions under a codename based on desserts, such as Apple Pie,
Banana Bread, Cupcake, Donut, Éclair, Froyo, Gingerbread, Jellybeans, KitKat, Lollipop,
marshmallow, nougat etc. and made a lot of changes and additions to the android platform.
The following table lists the different version details of android which is released by Google from
2007 to till date.
Android 8.0 26 O
Android Architecture
Android architecture is a software stack of components to support mobile device needs. Android
software stack contains a Linux Kernel, collection of c/c++ libraries which are exposed through an
application framework services, runtime, and application.
Following are main components of android architecture those are
1. Applications
2. Android Framework
3. Android Runtime
4. Platform Libraries
5. Linux Kernel
In these components, the Linux Kernel is the main component in android to provide its operating
system functions to mobile and Dalvik Virtual Machine (DVM) which is responsible for running a
mobile application.
Applications
The top layer of the 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.
Application Framework
The Application Framework provides the classes used to create Android applications. 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 a particular class and
make that class helpful for the Application 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.
Android Runtime
Android Runtime environment is an important part of Android rather than an internal part and it
contains 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.
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.
The core libraries in android runtime will enable us to implement android applications using
standard JAVA programming language.
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 support for Android
development.
The following are the summary details of some core android libraries available for android
development.
• Media library for playing and recording audio and video formats
• The Surface manager library to provide a display management
• SGL and OpenGL Graphics libraries for 2D and 3D graphics
• SQLite is for database support and FreeType for font support
• Web-Kit for web browser support and SSL for Internet security.
Linux Kernel
Linux Kernel is a bottom layer and heart of the android architecture. It manages 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 provide 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.
To make the android development environment setup process simple Google introduced a new
android IDE called Android Studio. The Android Studio will contain all the required components
like Eclipse IDE, Eclipse Plugin and Android SDK so we do not need to download the components
separately.
Android Studio is the official IDE for android development and it is based on IntelliJ IDEA software.
It is available for Windows, MAC, and LINUX operating systems.
We can download the latest version of Android Studio from the following URL.
Here, I am going to explain how to install android studio on a windows machine which is having
windows 10 operating system.
This is how we can set up an Android development environment on a windows machine which is
having windows 10 operating system using android studio IDE.
*Note: This is the 2.3.3 version of Android Studio. Newer version may be different look.
• Select the different platforms and SDK targets like as shown below based on our requirements.
• Wear: We use this option for Android Watches which we can wear to our hand and use the
same functionality as we do with the Android devices. You can call, set the alarm, capture
images, and many more things easily.
• TV: We use this option for SmartIPTV which is very common these days. We can see our
favorite channels like we see in our Home Televisions and make the changes in the channel
easily.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<manifest>: manifest is the root element of the AndroidManifest.xml file. It has package attribute
that describes the package name of the activity class.
<application>: application is the sub element of the manifest. It includes the namespace
declaration. This element contains several sub elements that declares the application component
such as activity etc.
The commonly used attributes are of this element are icon, label, theme etc.
• android:icon represents the icon for all the android application components.
• android:label works as the default label for all the application components.
• android:theme represents a common theme for all the android activities.
<activity>: activity is the sub element of application and represents an activity that must be
defined in the AndroidManifest.xml file. It has many attributes such as label, name, theme,
launchMode etc.
android:label represents a label i.e. displayed on the screen.
android:name represents a name for the activity class. It is required attribute.
<intent-filter>: intent-filter is the sub-element of activity that describes the type of intent to
which activity, service or broadcast receiver can respond to.
<action>: It adds an action for the intent-filter. The intent-filter must have at least one action
element.
Run Android Hello World App
To run android applications, we need to click on Run button or press Shift + F10 like as shown
below
Now our android hello world application will show the result like as shown below
Here, I am going to use my android phone for the testing purpose, for using phone into a android
studio, first turn on developer options as well as USB debugging from settings of your phone. For
that you can follow these steps.
You can select, USB or Wi-Fi as well. Here just select name of your phone and then click on run to
test app on your phone.
• As we know the modern JVM is high performance and provides excellent memory
management. But it needs to be optimized for low-powered handheld devices as well.
• The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile devices.
It optimizes the virtual machine for memory, battery life and performance.
• Dalvik is a name of a town in Iceland. The Dalvik VM was written by Dan Bornstein.
• The Dex compiler converts the class files into the .dex file that run on the Dalvik VM. Multiple
class files are converted into one dex file.
Below is the compiling and packaging process from the source file:
The javac tool compiles the java source file into the class file.
The dx tool takes all the class files of your application and generates a single .dex file. It is a platform-
specific tool.
The Android Assets Packaging Tool (aapt) handles the packaging process.