Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to ANDROID

Similar presentations


Presentation on theme: "Introduction to ANDROID"— Presentation transcript:

1 Introduction to ANDROID

2 Introduction Mobile operating system that is based on a modified version of Linux. Developed by Google and later the Open Handset Alliance (OHA) Allows writing managed code in the Java language Unveiling of the Android platform was announced on 5 November 2007 with the founding of OHA

3 History of Android Google acquired the startup company Android Inc. in 2005 to start the development of the Android Platform. The key players at Android Inc. included Andy Rubin, Rich Miner, Nick Sears, and Chris White. In late 2007, a group of industry leaders came together around the Android Platform to form the Open Handset Alliance ( The Android SDK was first issued as an “early look” release in November In September 2008 T-Mobile announced the availability of the T-Mobile G1, the first smartphone based on the Android Platform. A few days after that, Google announced the availability of Android SDK Release Candidate 1.0. In October 2008, Google made the source code of the Android Platform available under Apache’s open source license.

4 What is Open Handset Alliance?
“… Open Handset Alliance™, a group of 47 technology and mobile companies have come together to accelerate innovation in mobile and offer consumers a richer, less expensive, and better mobile experience. Together we have developed Android™, the first complete, open, and free mobile platform. We are committed to commercially deploy handsets and services using the Android Platform. “

5 Introduction → It's a consortium of several companies Google Android
What is the Open Handset Alliance (OHA)? → It's a consortium of several companies Google Android

6 Open Handset Alliance Members

7 Phones HTC G1, Droid, Tattoo Motorola Droid (X) Sony Ericsson
Suno S880 Samsung Galaxy 7

8 Tablets Velocity Micro Cruz Gome FlyTouch Acer beTouch Toshiba Android
SmartBook Cisco Android Tablet Dawa D7 8

9 OHA Google goes wireless Forming the OHA
Manufacturers : Designing the android handsets Mobile Operators : Delivering the android experience Content Providers: Developing Android apps

10 Android’s Context: Mobile Market Player
Stakeholders: Mobile network operators want to lock down their networks, controlling and metering traffic. Device manufacturers want to differentiate themselves with features, reliability, and price points. Software vendors want complete access to the hardware to deliver cutting- edge applications.

11 Android Versions

12 Version and API Alpha (1.0) ----- 1 Beta (1.1) ----- 2
Cupcake (1.5) Donut (1.6) Eclair (2.0–2.1) ,6,7 Froyo (2.2–2.2.3) Gingerbread (2.3–2.3.7) ,10 Honeycomb (3.0–3.2.6) ,12,13 Ice Cream Sandwich (4.0–4.0.4) ,15 Jelly Bean (4.1–4.3.1) ,17,18 KitKat (4.4–4.4.4) ,20 Lollipop (5.0–5.0.2)

13 Features of Android Storage Connectivity Messaging Web browser
Media support Hardware support Multi-touch Multi-tasking Flash support Tethering

14 Platform - The Android Software Stack
14

15 Android S/W Stack - Application
Android provides a set of core applications: Client SMS Program Calendar Maps Browser Contacts Etc All applications are written using the Java language. 15

16 Android S/W Stack – App Framework
Most of the application framework accesses these core libraries through the Dalvik VM, the gateway to the Android Platform 16

17 Android S/W Stack – App Framework (Cont)
Feature Role View System Used to build an application, including lists, grids, text boxes, buttons, and embedded web browser Content Provider Enabling applications to access data from other applications or to share their own data Resource Manager Providing access to non-code resources (localized string , graphics, and layout files) Notification Manager Enabling all applications to display customer alerts in the status bar Activity Managing the lifecycle of applications and providing a common navigation backstack 17

18 Location Manager

19 Notification Manager

20 Notification Manager How background app interact with users
Consistent notification presentation

21 View System

22 View System

23 Android S/W Stack - Libraries
Including a set of C/C++ libraries used by components of the Android system Exposed to developers through the Android application framework 23

24 Android S/W Stack - Libraries
The media libraries are based on PacketVideo’s ( OpenCORE. These libraries are responsible for recording and playback of audio and video formats. A library called Surface Manager controls access to the display system and supports 2D and 3D. The WebKit library is responsible for browser support; it is the same library that supports Google Chrome and Apple Inc.’s Safari. The FreeType library is responsible for font support. SQLite ( is a relational database that is available on the device itself. SQLite is also an independent open source effort for relational databases and not directly tied to Android. You can acquire and use tools meant for SQLite for Android databases as well.

25 Android S/W Stack - Runtime
Core Libraries Providing most of the functionality available in the core libraries of the Java language APIs Data Structures Utilities File Access Network Access Graphics Etc 25

26 The Dalvik runtime is optimised for mobile applications
Run multiple VMs efficiently Each app has its own VM Minimal memory footprint

27 Android S/W Stack – Runtime (Cont)
Dalvik Virtual Machine (Cont) Executing the Dalvik Executable (.dex) format .dex format is optimized for minimal memory footprint. Compilation Relying on the Linux Kernel for: Threading Low-level memory management 27

28 Android applications are compiled to Dalvik bytecode
Write app in Java Compiled in Java Transformed to Dalvik bytecode Linux OS Loaded into Dalvik VM

29 Android S/W Stack – Linux Kernel
Relying on Linux Kernel 2.6 for core system services Memory and Process Management Network Stack Driver Model Security The supplied device drivers include Display, Camera, Keypad, WiFi, Flash Memory, Audio, and IPC (interprocess communication). Providing an abstraction layer between the H/W and the rest of the S/W stack @2010 Mihail L. Sichitiu 29

30 Platform Google Android Network Connectivity
It supports wireless communications using: GSM mobile-phone technology 3G Edge Wi-Fi networks Google Android

31 Software development Google Android Development requirements Java
Android SDK Google Android

32 Software development Google Android IDE and Tools Android SDK
Android SDK Class Library Developer Tools Emulator and System Images Documentation and Sample Code Eclipse IDE + ADT (Android Development Tools) Reduces Development and Testing Time Makes User Interface-Creation easier Makes Application Description Easier Google Android

33 Advantages Google Android
Here are a few other advantages Android offers you as a developer: The Android SDK is available for Windows, Mac and Linux, so you don’t need to pay for new hardware to start writing applications. An SDK built on Java. If you’re familiar with the Java programming language, you’re already halfway there. By distributing your application on Android Market, it’s available to hundreds of thousands of users instantly. You’re not just limited to one store, because there are alternatives, too. For instance, you can release your application on your own blog. Amazon have recently been rumoured to be preparing their own Android app store also. As well as the technical SDK documentation, new resources are being published for Android developers as the platform gains popularity among both users and developers.  Google Android

34 Application Building Blocks
Activity IntentReceiver Service ContentProvider

35 Activities Typically correspond to one UI screen But, they can:
Be faceless Be in a floating window Return a value

36 IntentReceivers Components that respond to broadcast ‘Intents’
Way to respond to external notification or alarms Apps can invent and broadcast their own Intent

37 Intents Think of Intents as a verb and object; a description of what you want done E.g. VIEW, CALL, PLAY etc.. System matches Intent with Activity that can best provide the service Activities and IntentReceivers describe what Intents they can service

38 Intents “Pick photo” Photo Gallery Home Picasa Contacts GMail Chat
Blogger Blogger

39 Services Faceless components that run in the background
E.g. music player, network download etc…

40 ContentProviders Enables sharing of data across applications
E.g. address book, photo gallery Provides uniform APIs for: querying delete, update and insert. Content is represented by URI and MIME type

41 Android Development Framework

42 Android software Development Kit (SDK) includes :
Android APIs Development Tools The Android Virtual Device Manager and Emulator Full Documentation Sample Code Online Support-

43 DVM Dalvik is open-source software. Dan Bornstein originally wrote Dalvik VM which is responsible for running apps on Android devices. It is a Register based Virtual Machine. It is optimized for low memory requirements. It has been designed to allow multiple VM instances to run at once. Relies on the underlying OS for process isolation, memory management and threading support. Operates on DEX files. All hardware and system service access is managed using Dalvik (middle tier)

44 Development Environment
JDK Software Development Kit (SDK) IDE – Eclipse Eclipse plug-in - ADT Android Emulator, Virtual Device Manager Debugger – Dalvik Debug Monitoring Service(DDMS) Android Asset Packaging Tool (AAPT) --- .apk Android Debug Bridge( ADB)

45 Setup Android SDK Download Android SDK and extract the zip file to an arbitrary folder E.g.: extract to C:\ The SDK will be used by ADT in eclipse(located in adt- bundle../eclipse

46 Setup ADT plugin Install Eclipse ADT plugin
Eclipse must be J2EE edition Update site: ssl.google.com/android/eclips e/ Install all the plugins in the repository Restart needed after installation

47 Configure ADT Plugin Open eclipse Window->Preferences, select Android Setup the SDK location as the folder where you extracted the downloaded SDK zip file

48 Setup SDK APIs Open Window->Android SDK and AVD Manager
Click Available Packages and then choose proper APIs to install, the latest may be the best

49 An  Android  Virtual  Device  (AVD)  is  a  configuration  of  
emulator  options   An  AVD  includes:   A  hardware  profile   A  platform     Other  options   ▪e.g.,  emulator  skin,  screen  dimensions,  SD  card  size   A  storage  area  Create  AVDs using  Android  SDK  and  AVD   Manager  tool  

50 Setup Emulators After SDK APIs installation, click Virtual Devices
Click new, there will be a dialog input a name choose a running target and a skin specify the SD card size

51 Ready… Now you may start the AVD Click start to start the new AVD
First start-up may take a very long time

52 1. DDMS What’s happening under the surface Debugging tool -- to interrogate active processes, view stack, watch and pause active threads ADB Client server app – to connect with android emulator. 3 components- daemon running in emulator - service that runs on your hardware - client app that communicate with daemon through service

53 Android SDK Documentation
Home SDK --- version and NDK, release notes Dev Guide Design and development Reference – Android APIs Resources – Technical articles and tutorials Videos Blog

54 Developing for mobile devices
Hardware imposed design consideration Be Efficient Expect Limited Capacity Design for small screens Expect low speeds, high latency At what cost

55 Android Component’s life cycle

56 Android Components Broadcast Receivers Content Providers Services and
Activities.

57 During execution of onReceive() ---- alive
As soon as onReceive() returns ---destroyed. Because of this short lifetime there are some restrictions on what you can do inside this function. For example, its invalid to use bindService() or registerReceiver()  functions from inside onReceive(). 

58 Static and dynamic broadcast receivers
Static broadcast --- AndroidManifest.xml dynamic registerReceiver() function.

59 Content Provider content providers are never destroyed,  they exist for the entire lifetime of their process. It is considered alive on call to onCreate() and until process that contains this component is killed. shutdown(). ---introduced in API Level 11 and may be implemented by Content Provider. Unit tests may call it in order to guarantee unit test isolation.

60 Service service is alive between calls to onCreate() and onDestroy() functions. 

61 Activity Refer Activity Life Cycle concepts

62 ‘Hello World’ on Android

63 Create a new Android Project
Open File->New- >Android project Project name Build Target Application name Package name Create Activity

64 Hello World Project src: source folder gen: SDK generated file
android 2.2: reference lib assets: binary resources res: resource files and resource description files AndroidManifest.xml: application description file default.properties: project properties file

65 Say Hello World modify HelloWorld.java

66 Run Hello World Select HelloWorld Project, Run->Run as->Android Application ADT will start a proper AVD and run HelloWorld app on it

67 Behind HelloWorld #1 R.java, generated by Android SDK, represents all the resources of the app. resources are all in res folder resources are pre-compiled into binary format /* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * aapt tool from the resource data it found. It * should not be modified by hand. */ package sample.hello; public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; public static final class layout { public static final int main=0x7f030000; public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000;

68 Behind HelloWorld #2 res/layout , contains layout declarations of the app, in XML format, UIs are built according to the layout file Linear Layout main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> TextView, display static text A reference to String resource ‘hello’

69 Behind HelloWorld #3 res/values, contains string declarations or other values(e.g.:colors) of the app string.xml, contains string resources <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, HelloWorld!</string> <string name="app_name">HelloWorld</string> </resources> referenced in res/layout/main.xml referenced in AndroidManifest.xml

70 Behind HelloWorld #4 res/drawable, contains all image resources
folders may have suffixes, app will choose the most suitable one, so do the other resources three folders: drawable-ldpi, drawable-hdpi, drawable-mdpi, each contains an icon.png file app will choose the proper icon according to the device DPI reference other folders we may use in future menu, anim (animation), xml ( preference and searchable)

71 Behind HelloWorld #5 AndroidManifest.xml describe the application
declare app’s name, version, icon, permission, etc… declare the application's components: activity, service ,receiver or provider <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="sample.hello" android:versionCode="1" android:versionName="1.0"> <application <activity android:name=".HelloWorld" <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER”/> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="8" /> </manifest>

72 Core Components-Activity #1
Basically, An activity presents a visual user interface for one focused endeavor the user can undertake An application might consist of just one activity or several, each Activity is derived from android.app.Activity and should be declared in AndroidManifest.xml file Each activity is given a default window to draw in, the window may be full screen or smaller and on top of other window The visual content of the window is provided by a hierarchy of views — objects derived from the base View class Activity.setContentView() method is used to set a certain hierarchy of view objects

73 Core Components-Activity #2
Activities are activated by asynchronous messages called intents An intent is an Intent object that holds the content of the message The action being requested or the URI of the data to act on The <intent-filter> label in AndroidManifest.xml file specifies the Intent that can start the Activity declares the main activity, it will be started automatically when the app starts An activity is launched (or given something new to do) by passing an Intent object to Context.startActivity() or Activity.startActivityForResult()

74 Activity lifecycle

75 Other Core Components Service Broadcast receivers Content providers
A service doesn't have a visual user interface, runs in the background for a period of time Broadcast receivers a component that does nothing but receive and react to broadcast announcements Content providers A content provider makes a specific set of the application's data available to other applications. The data can be stored in the file system, in an SQLite database, or in any other manner that makes sense

76 Beyond HelloWorld #1 Build up an app that you can input your greetings and display your greetings Input: EditText Display: TextView Of course, we have to add an button Edit res/layout/main.xml file to add these components each has an android:id property, used to reference it in code

77 Beyond HelloWorld #2 modify HelloWorld.java
firstly get the references declared in main.xml then add event response for Button

78 Beyond HelloWorld #3 Finished! Run->Run as->Android Application
Quite easy, isn’t it?

79 More…

80 Useful Materials Android Official Site http://www.android.com
Android SDK, Tutorial, Concepts and API docs Android Development Community 30 Days Android Apps Development


Download ppt "Introduction to ANDROID"

Similar presentations


Ads by Google