Introduction To Mobile Computing With Android: Prof. Manish Kumar Joshi, Assistant Professor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Introduction to Mobile Computing

with Android
Prof. Manish Kumar Joshi, Assistant Professor
IT & Computer Science
CHAPTER-2
Getting Started with Android
Overview
Android is a Linux based operating system it is designed primarily for
touch screen mobile devices such as smart phones and tablet computers.
The operating systems have developed a lot in last 15 years starting from
black and white phones to recent smart phones or mini computers. One of
the most widely used mobile OS these days is android. The android is
software that was founded in Palo Alto of California in 2003.
Android Architecture
The android is a operating system and is a stack of software components
which is divided into five sections and four main layers that is
• Linux Kernel
• Libraries
• Android Runtime
• Application Framework
Linux Kernel

The android uses the powerful Linux kernel and it supports wide range
of hardware drivers. The kernel is the heart of the operating system that
manages input and output requests from software. This provides basic
system functionalities like process management, memory management,
device management like camera, keypad, display etc the kernel handles
all the things. The Linux is really good at networking and it is not
necessary to interface it to the peripheral hardware. The kernel itself
does not interact directly with the user but rather interacts with the shell
and other programs as well as with the hard ware devices on the
system.
Application Framework
Libraries

The on top of a Linux kennel there is a set of libraries including open


source web browser such as webkit, library libc. These libraries are used
to play and record audio and video. The SQLite is a data base which is
useful for storage and sharing of application data. The SSL libraries are
responsible for internet security etc.
Android Runtime

The android runtime provides a key component called Dalvik Virtual


Machine which is a kind of java virtual machine. It is specially designed
and optimized for android. The Dalvik VM is the process virtual machine
in the android operating system. It is software that runs apps on android
devices.
The Dalvik VM makes use of Linux core features like memory
management and multithreading which is in java language. The Dalvik
VM enables every android application to run it own process. The Dalvik
VM executes the files in the .dex format.
The Application Components

Application components are main building blocks of an Android


application. The application manifest file loosely binds these components
together.
There are mainly 4 components:
• Activities
• Services
• Broadcast Receivers
• Content Provider
Android SDK

Android development starts with the Android SDK (Software Development


Kit). While there are many different programming languages and a host of
IDEs you can use to create an app, the SDK is a constant.
The Android SDK can be broken down into several components. These
include:

• Platform-tools
• Build-tools
• SDK-tools
• The Android Debug Bridge (ADB)
• Android Emulator
Using SDK Manager

While Android Studio will


normally let you know when
you need to update
something, you can also
manage updates to the SDK
manually via the manager.
You’ll find this in Android
Studio if you navigate to Tools
— Android — SDK Manager.
You’ll see there are three tabs
here for SDK Platforms, SDK
Tools, and SDK Update Sites.
Using SDK Manager

You’ll likewise find the AVD


Manager under Tools —
Android — AVD Manager.
This lets you build your own
emulators. You’ll choose the
size of the device and some
other specifications, and you’ll
be prompted to download the
requisite x86 system image if
it’s not already installed.
Using The Android Device Monitor

The Android Device Monitor encapsulates DDMS and can be found under
– you guessed it – Tools — Android — DDMS. This works with either an
emulator or a connected device and will go a little deeper in monitoring the
way your Android device and app are behaving.
Using ADB

Using ADB is a little different.


To do this, you will need to find
your Android SDK installation
folder and navigate to the
platform-tools directory. On
Windows, hold shift and right
click anywhere in the folder to
open a command line. On
Mac, just open Terminal from
Launchpad (usually found in
the Other folder).
Advantages of Android

• It supports wireless communication using 3G, 4G, 5G, Wi-Fi, EDGE and
Bluetooth networks.
• It is Linux based and open-source.
• It has Media and Storage support.
• It supports all Google services like Gmail, Chrome, Location manager,
Google maps, Drive, play Store etc.
• It supports multitasking and many more.
Android Studio Installation & Setup: Step 0

1. Installing Java
Development Kit
2. Set environment
variable “JAVA_HOME”
to JDK installation
directory.
Step 1 (for Windows)

1. Goto
developers.android.co
m/studio and download
android studio
2. After downloading
studio, launch android
studio and continue to
next steps.
Step 1 (for MacOS)

1. Goto
developers.android.co
m and click on
download options and
select the android
studio for macOS , the
one with .dmg file
extension.
2. Launch the installation
file and continue to the
next steps.
Step 2
1. Launching android studio for the
first time, it will run setup wizard
a) Choose “don’t import
previous settings”
b) In “welcome”, choose “next”
c) In “install type”, choose
“standard”
d) Select UI theme.
2. In SDK setup make sure virtual
device is selected and carry on
to the installation steps.
Step 3
Set up Emulator
1. In android studio select “Tools” -> Android -> AVD manager
2. Choose a device
3. Select and system image
4. Verify configuration, finish.
Android Manifest File
Every project in Android includes
a manifest file, which is
AndroidManifest.xml, stored in
the root directory of its project
hierarchy. The manifest file is an
important part of our app
because it defines the structure
and metadata of our application,
its components, and its
requirements.
AndroidManifest.xml
This file includes nodes for
each of the Activities, Services,
Content Providers and
Broadcast Receiver that make
the application and using Intent
Filters and Permissions,
determines how they co-
ordinate with each other and
other applications.
AndroidManifest.xml
A manifest file includes the nodes that define the application components,
security settings, test classes and requirements that make up the
application. Some of the manifest sub-node tags that are mainly used are:
• uses-sdk
• uses-configuration
• uses-features
• permission
• support-screens
• intent-filters
• application
Android LifeCycle
As a user navigates through the app, Activity instances in your app
transition through different stages in their life-cycle. The Activity class
provides a number of callbacks that allow the activity to know that a state
has changed: that the system is creating, stopping, or resuming an activity,
or destroying the process in which the activity resides.
Android LifeCycle
LifeCycle Methods
In general, activity lifecycle has seven callback methods:
1. onCreate()
2. onStart()
3. onResume()
4. onPause()
5. onStop()
6. onRestart()
7. onDestroy()
Android LifeCycle
When you open the app it will go through below states:
onCreate() –> onStart() –> onResume()
When you press the back button and exit the app
onPaused() — > onStop() –> onDestory()
When you press the home button
onPaused() –> onStop()
After pressing the home button, again when you open the app from a
recent task list
onRestart() –> onStart() –> onResume()
After dismissing the dialog or back button from the dialog
onResume()
Android LifeCycle
If a phone is ringing and user is using the app
onPause() –> onResume()
After the call ends
onResume()
When your phone screen is off
onPaused() –> onStop()
When your phone screen is turned back on
onRestart() –> onStart() –> onResume()
www.paruluniversity.ac.in

You might also like