Chapter 1 Introduction to android
Chapter 1 Introduction to android
Berihun G.
1
Outline
• What is Android?
• Introduction (The Android Stack)
• Android Architecture
• Application Components
• Android Development Process
2
What is Android?
• Android is a software stack for mobile devices
that includes an operating system,
middleware(Software that act as a bridge
between an operating system or database) and
key applications.
• Android is a mobile operating system that is
based on a modified version of Linux.
3
cont.…
• Android is a comprehensive open source
platform designed for mobile devices.
• Comprehensive platform: complete
software stack for mobile devices.
• Open source: the entire stacks are free
to use.
• Google’s mobile platform
Runs Smartphone ,tablet computers ,
(Samsung Tablets , Similar to iPad)
Most popular
• Development platform
Multiplatform
Based on Java
Plugins for Eclipse, Android Studio
4
cont.…
• Android is an embedded OS(different kind
of machine or HW+SW)
• Android applications are written using
the Java framework, but Android is
not Java. Standard Java libraries such
as Swing are not supported.
• Android uses its own libraries.eg Time
Picker, global positioning.
• The Android OS is open source, which
means developers can view and use
any of the system source code
5
Android Features
• Storage: Uses SQLite, a lightweight relational
database, for data storage.
• Connectivity: Supports GSM/EDGE, IDEN,
CDMA, EV-DO, UMTS, Bluetooth (includes A2DP
and AVRCP), WiFi, LTE, and WiMAX.
• Messaging :Supports both SMS and MMS.
• Web browser: Based on the open-source
WebKit, together with Chrome’s V8 JavaScript
engine
• Media support: includes support for the
following media: H.263, H.264 (in 3GP or MP4
container), MPEG-4 SP, AMR, AMR-WB (in 3GP
container), AAC, HE-AAC (in MP4 or 3GP
container), MP3, MIDI, Ogg Vorbis, WAV, JPEG,
PNG, GIF, and BMP
6
cont.…
• Hardware support: Accelerometer
Sensor, Camera, Digital Compass,
Proximity Sensor, and GPS
• Multi-touch :Supports multi-touch
screens
• Multi-tasking: Supports multi-tasking
applications
• Flash support: Android 2.3 supports
Flash 10.1.
• Tethering: Supports sharing of
Internet connections as a
wired/wireless hotspot
7
Android Stack
• Android operating system is like a cake
consisting of various layers. Each layer
has its own characteristics and purposes.
• Android is built on top of Linux.
• Way Linux?
– Its open source
– Portability-easy to integrate with different
hardware
– Security-Linux is highly secured system.
– Features-Linux provides:
• Hardware abstraction layer
• Memory management
• Process management
• Networking
8
…
• Software stack for mobile
devices
• Developed and managed
by open handset Alliances
• Open sourced under
Apache License
9
Android Architecture
Android Architecture – Linux Kernel
12
Android Architecture -‐ Runtime…
• Dalvik VM
– Every android application runs
in its own process with its own
instances of the dalvik vm
– Dalvik VM has been written
so that a device can run
multiple VMs
efficiently
– Register‐based virtual
machine
13
Android Architecture -‐ Runtime…
• Executes files in the Dalvik Executable (.dex) format, which
is optimized for minimal memory footprint
• Runs classes compiled by a Java language compiler
transformed into the .dex format
14
Android Architecture -‐ Runtime…
• Features
• System C Library (Bionic) a
version of libc : for technology and
license purpose
• Includes a set of C/C++ • Media Libraries supporting playback
libraries used by various and recording of popular audio/video
formats
components of the
• Surface Manager (Surface Flinger)
Android
• Audio Manager (Audio Flinger)
system • LibWebCore (WebKit)
• Exposed to developers • SGL
through the Android • 3D Libraries: Open GL ES
application framework • WebKit browser support
• SQLite
15
Android Architecture -Application Frame work
16
Android Architecture -Application Frame work…
• Set of service and features
17
Android Architecture -Applications
18
Most Popular Android Version September 2018
Old Version: Android 1.0, 1.1 to 1.5 (Cupcake), 1.6 (Donut), 2.0/2.1 (Eclair), 2.2
(Froyo), 2.3 (Gingerbread), to 3.0 (Honeycomb), 4.0 (Ice Cream Sandwich
19
Continued..
20
Android Applications
• Android applications are written in Java
• The compiled Java code (along with any data
and resourcefiles required by the application)
is bundled into an Android package (.apk)
21
What is APK?
• An application is a single application package (APK) file.
An APK file roughly has three main components. An API
consists of the following major components:
• Dalvik executable
– This is all your Java source code compiled down to a Dalvik
executable.
– This is the code that runs your application.
• Resources
– Resources are everything that is not code. Your application may
contain a number of images and audio/video clips, as
well as numerous XML files describing layouts,
language packs, and so on. Collectively, these items
are the resources.
• Native libraries
– Optionally, your application may include some native code, such
as C/C++ libraries. These libraries could be packaged
together with your APK file.
22
23
Java and Android
Android API
AWT/Swing
Java SE
=
+
–
Still We can have it the old Classic Way (Procedural )
Android and Java
• Android java is an nonstandard collection of java.
way?
• java have different Editions (Java Packaging)
– Java ME (Mobile Edition)
– java SE(Standard Edition )
– Java EE(Enterprise Edition)
• but android is not part of these editions
• So why Java ::: market issue because tons of
java coders in the world
24
Basic Application Components
25
Activity
• An activity is usually a single screen that the
user sees on the device at one time.
undertake:
– Extends the Activity base class
– Displays user interface controls (views)
– Provides for user interaction
26
Service
• service runs in the background for an indefinite
period of time.
– Example: play music, network download, etc.
– Does not have a user interface
– extends the Service base class.
• We can bind to a running service (or start the service if it's
not already running)
27
Broadcast Receivers
• Receives and reacts to broadcast announcements (Intents)
– Many broadcasts originate in system code.
– E.g. announcements that a picture is taken, that the time
zone has changed, that the battery is low, etc.
– Applications can also initiate ate broadcasts.
• E.g. to let other applications know that some data has
been downloaded to the device and is available for
them to use
• Do not have a user interface
• May start an activity in response to the received
broadcast.
• May also use notifications to alert the user.
28
Content Providers
• Makes a specific set of the applications data available to other
applications.
– Data can be stored in the file system, in an SQLite, or in any
other manner that makes sense
– extends the ContentProvider base class to implement a standard
set of methods that enable other applica5ons to retrieve and
store
data of the type it controls
• Applications do not call these methods directly.
– They use a ContentResolver object and call its methods instead
– ContentResolver can talk to any content provider
29
Installing and Configuring development Tools
• Android Studio: An easy to use Integrated
Development Environment (IDE) that brings
together Java and the Android SDK to make it
simple to write Android apps.
• Java JDK: The Java Development Kit. Lays
the foundation for the Android SDK.
• Android SDK: Included in Android Studio.
– Provides access to Android libraries and
allows
you to develop for Android.
30
Installing Android Studio
• To download Android Studio,
• https://developer.android.com/studio
31
Adding SDK Packages
• 1. Choose Tools⇒Android⇒SDK Manager to launch the SDK
manager tool.
•
32
Setting Up an Emulator
• Like a real android device and allow you to test your application without having a
real device.
1. Choose Tools⇒Android⇒AVD Manager.
The AVD Manager dialog box opens.
33
34
35
Understanding Project Structure
36
app directory
37
• What the Android manifest file contains
– The name of your application ID for the
application, which is the unique identifier for your
application in the Android system as well as in the
Google Play Store
– The icon for your application
– The components of the application, such as the
activities and background services
– The declaration of the permissions your
application requires to run
38
Viewing the build.gradle file
The compileSdkVersion tells Android Studio what version of the Android SDK you
are
compiling against. This version is set based off the choices you made when you went
through the New Activity Wizard earlier in this chapter.
The buildToolsVersion tells Android Studio what version of the build tools to use
(which is the version of the tools that you installed on your computer).
The applicationId must match the package that you set in your AndroidManifest.xml
file.
39
Lab session
What you'll learn
•How to create a project in Android Studio.
•How to create an emulated Android device.
•How to run your app on the emulator.
•How to run your app on your own physical
device, if you have one.
40