1. Android Studio
Android Studio
Mrs. S. JEBA GNANA RUBY,
Assistant Professor,
Department of Computer Applications,
Ayya Nadar Janaki Ammal College,
Sivakasi.
2. Android studio Introduction:
• Android is a complete set of software for mobile devices such as tablet computers, notebooks, smartphones, electronic book
readers, set-top boxes etc.
• It contains a linux-based Operating System, middleware and key mobile applications.
• It can be thought of as a mobile operating system. But it is not limited to mobile only. It is currently used in various devices
such as mobiles, tablets, televisions etc.
What is android:
Android is a software package and linux based operating system for mobile devices such as tablet computers and smartphones.
It is developed by Google and later the OHA (Open Handset Alliance). Java language is mainly used to write the android code
even though other languages can be used.
The goal of android project is to create a successful real-world product that improves the mobile experience for end users.
There are many code names of android such as Lollipop, Kitkat, Jelly Bean, Ice cream Sandwich, Froyo, Ecliar, Donut etc which is
covered in next page.
What is Open Handset Alliance (OHA)
It's a consortium of 84 companies such as google, samsung, AKM, synaptics, KDDI, Garmin, Teleca, Ebay, Intel etc.
It was established on 5th November, 2007, led by Google. It is committed to advance open standards, provide services and deploy
handsets using the Android Plateform.
3. Features of Android:
After learning what is android, let's see the features of android. The important features of android are given below:
1) It is open-source.
2) Anyone can customize the Android Platform.
3) There are a lot of mobile applications that can be chosen by the consumer.
4) It provides many interesting features like weather details, opening screen, live RSS (Really Simple Syndication) feeds
etc.
Categories of Android applications
There are many android applications in the market. The top categories are:
o Entertainment o Tools
o Communication o Productivity o Personalization o Music and Audio o
Social
o Media and Video o Travel and Local etc.
4. History of Android:
The history and versions of android are interesting to know. The code names of android ranges from A to J currently, such as
Aestro, Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread,
honeycomb, Ice Cream, Sandwitch, Jelly Bean, KitKat and Lollipop. Let's understand the android history in a sequence.
1) Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States in October, 2003.
2) In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary of Google Incorporation.
3) The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris White and Nick Sears.
4) Originally intended for camera but shifted to smart phones later because of low market for camera only.
5) Android is the nick name of Andy Rubin given by coworkers because of his love to robots.
6) In 2007, Google announces the development of android OS.
7) In 2008, HTC launched the first android mobile.
5. Android Versions, Codename and API
Let's see the android versions, codenames and API Level provided by Google.
Version Code name API Level
1.5 Cupcake 3
1.6 Donut 4
2.1 Eclair 7
2.2 Froyo 8
2.3 Gingerbread 9 and 10
3.1 and 3.3 Honeycomb 12 and 13
4.0 Ice Cream Sandwitch 15
4.1, 4.2 and 4.3 Jelly Bean 16, 17 and 18
4.4 KitKat 19
5.0 Lollipop 21
6.0 Marshmallow 23
7.0 Nougat 24-25
8.0 Oreo 26-27
6. Android Architecture:
Android architecture or Android software stack is
categorized into five parts:
1. linux kernel
2. native libraries
(middleware),
3. Android Runtime
4. Application Framework
5. Applications
1) 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.
2) Native Libraries
On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType, SQLite, Media, C runtime library (libc) etc.
The WebKit library is responsible for browser support, SQLite is for database, FreeType for font support, Media for playing and
recording audio and video formats.
7. 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.
4) 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.
5) 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 kernal.
Android Core Building Blocks
An android component is simply a piece of code that has a well defined life cycle e.g.
Activity, Receiver, Service etc.
The core building blocks or fundamental components of android are activities, views,
intents, services, content providers, fragments and AndroidManifest.xml.
8. Activity
An activity is a class that represents a single screen. It is like a Frame in AWT.
View
A view is the UI element such as button, label, text field etc. Anything that you see is a view.
Intent
Intent is used to invoke components. It is mainly used to:
o Start the service o Launch
an activity o Display a web
page o Display a list of
contacts o Broadcast a
message o Dial a phone call
etc.
Service
Service is a background process that can run for a long time.
There are two types of services local and remote. Local service is accessed from within the application whereas remote service is
accessed remotely from other applications running on the same device.
9. Content Provider
Content Providers are used to share data between the applications.
Fragment
Fragments are like parts of activity. An activity can display one or more fragments on the screen at the same time.
AndroidManifest.xml
It contains informations about activities, content providers, permissions etc. It is like the web.xml file in Java EE.
Android Virtual Device (AVD)
It is used to test the android application without the need for mobile or tablet etc. It can be created in different configurations to
emulate different types of real devices.
Android Emulator:
The Android emulator is an Android Virtual Device (AVD), which represents a specific Android device. We can use the Android
emulator as a target device to execute and test our Android application on our PC. The Android emulator provides almost all the
functionality of a real device. We can get the incoming phone calls and text messages. It also gives the location of the device and
simulates different network speeds. Android emulator simulates rotation and other hardware sensors.
Testing Android applications on emulator are sometimes faster and easier than doing on a real device. For example, we can transfer
data faster to the emulator than to a real device connected through USB.
The Android emulator comes with predefined configurations for several Android phones, Wear OS, tablet, Android TV devices.
11. Requirement and recommendations
The Android emulator takes additional requirements beyond the basic system requirement for Android Studio. These requirements are
given below:
o SDK Tools 26.1.1 or higher o 64-bit processor
o Windows: CPU with UG (unrestricted guest) support
o HAXM 6.2.1 or later (recommended HAXM 7.2.0 or later) o Install the emulator
o The Android emulator is installed while installing the Android Studio. However some components of emulator may or may not be
installed while installing Android Studio. To install the emulator component, select the Android Emulator component in the SDK
Tools tab of the SDK Manager. o Run an Android app on the Emulator
o We can run an Android app form the Android Studio project, or we can run an app which is installed on the Android Emulator as we
run any app on a device.
o To start the Android Emulator and run an application in our project:
1. In Android Studio, we need to create an Android Virtual Device (AVD) that the emulator can use to install and run your app. To
create a new AVD:-
12. o 1.1 Open the AVD Manager by clicking Tools > AVD Manager.
13. o 1.2 Click on Create Virtual Device, at the bottom of the AVD Manager dialog. Then Select Hardware page appears.
, Select Hardware
Android Studio
virtual Device Configuration
Choose a device definition
[o-
Category Name ▼
TV Pixel XL
Phone Pixel 3 XL
Wear 05 Pfsei a
Tablet Pixel 2 XL
Nam* * Play Start Sl» Htidutifcn □enslly
Pixel XL 5.5" 1440x2—560dpi
Pixel 3 XL 6,3B
1440x2...560dpi
r-
—
Pixel 3 i^ 5,46" 1080x2-440dpi
Pixel 2 X L 5.99" 1440x2...560dpi
Pixel 2 5,0* 1080x1.,,420dpi
Pixel 5,0* 1080xl.„420dpi
Nexus S 4.0* 430x800hdpi
Nexus One 3,7" 430x800hdpi
Nexus OP 5,7" 1440x2...560dpi
C£] Pixel 3
S,40' i
Size: large
Ratio: long
Density: 440dpi
New Hardware Profile import Hardware Profiles Clone Device..
Cancel Previous Next Finish
14. 1.3 Select a hardware profile and then click Next. If we don?t see the hardware profile we want, then we can create or import a
hardware profile. The System Image page appears.
Virtual Device Configuraton
System Image
Andfoid S;udi*
Select a system image
Rafojnmended Image* Other Image*
Google Inc.
Sister Im&se-
We recommend these Gdogte Play images because
this device is cornpaiibio with Google Play.
Ques-iions QD API level?
Sett thele. d d -ilritajiUon char t
Cancel Previous
0 Download u xBB Andhxdftt (Google PIT,)
Pie 26 *69 Andrfrid 9.0 (GOWQU- Play)
Oreo Download 27 AndtCtd P 1 (GOQQtt P.’Jfl
Oreo Download
II
x$$ AntlroW 6 0 (GQOQH: Pity)
Nougat Download li?5 m Anrtfc <17, J ! fCoq^r S
Nougat Download 2* xSS AndfroSd 7.0 (Google Play)
15. 1.4 Select the system image for the particular API level and click Next. This leads to open a Verify Configuration page.
Virtual Device Configuration
17. While the emulator is running, we can run the Android Studio project and select the emulator as the target device. We can also drag an
APKs file to install on an emulator, and then run them.
Dalvik Virtual Machine | DVM
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.
Let's see the compiling and packaging process from the source file:
18. The dx tool takes all the class files of your application and generates a single .dex file. It is a platform-specific tool.
Android Activity:
you have worked with C, C++ or Java programming language then you must have seen that your program starts from main() function.
Very similar way, Android system initiates its program with in an Activity starting with a call on onCreate() callback method. There is
a sequence of callback methods that start up an activity and a sequence of callback methods that tear down an activity as shown in the
below Activity life cycle diagram:
19. Activity
launched
User navigates to
the activity
Apps with higher priority need
memory
onCreatef)
~T~
onStartQ onRestartQ
i
onResume()
Activity
running
Another activity comes into
the foreground
I
onPause()
User returns to
the activity
_J
The activity is no
longer visible
User navigates to
the activity
- onStopO -
The activity is finishing or be ng
destroyed by the system
I
20. Sr.No
1
2
3
4
5
6 7
Callback & Description
onCreate()
This is the first callback and called when the activity is first created. onStart()
This callback is called when the activity becomes visible to the user. onResume()
This is called when the user starts interacting with the application. onPause()
The paused activity does not receive user input and cannot execute any code and called
when the current activity is being paused and the previous activity is being resumed.
onStop()
This callback is called when the activity is no longer visible. onDestroy()
This callback is called before the activity is destroyed by the system. onRestart()
This callback is called when the activity restarts after stopping it.