Slide 1

Slide 1 text

Marko Gargenta marakana.com ANDROID   OVERVIEW  

Slide 2

Slide 2 text

About  Marko  Gargenta   Developer of Android Bootcamp for Marakana. Instructor for 1,000s of developers on Android at Qualcomm, Cisco, Motorola, DoD and other great orgs. Author of Learning Android published by O’Reilly. Speaker at OSCON (3x), ACM, IEEE, SDC, AnDevCon. Co-Founder of SFAndroid.org Co-Chair of Android Open conference: AndroidOpen.com

Slide 3

Slide 3 text

Agenda   •  Android  Then  &  Now   •  Android  versions   •  The  Stack   •  Opera

Slide 4

Slide 4 text

ANDROID  THEN  &  NOW  

Slide 5

Slide 5 text

History  and  Possible  Future   2005   Google  buys  Android,  Inc.   Work  on  Dalvik  starts   2007   Open  Handset  Alliance  announced   Early  SoOware  Development  Kit   2008-­‐2010   Android  becomes  the  dominant   mobile  plaTorm   2011   Games,  Tablets,  TVs   Future?   Beyond  phones  

Slide 6

Slide 6 text

Vision  for  Android   Our goal is not just a single device. Our vision is a mobile platform that runs on many many different devices. – Eric Schmidt

Slide 7

Slide 7 text

PlaTorm  Versions   Version   API  Level   Nickname   Android  1.0   1   Android   Android  1.1   2   Android   Android  1.5   3   Cupcake   Android  1.6   4   Donut   Android  2.0   5   Éclair   Android  2.01   6   Éclair   Android  2.1   7   Éclair   Android  2.2   8   FroYo   Android  2.3   9   Gingerbread   Android  2.3.3   10   Gingerbread   Android  3.x   11,  12,  13   Honeycomb   Android  4.0   14   Ice  Cream  Sandwich  

Slide 8

Slide 8 text

Version  Distribu

Slide 9

Slide 9 text

Historical  Distribu

Slide 10

Slide 10 text

Add-­‐Ons   TouchWiz   MotoBlur   SenseUI  

Slide 11

Slide 11 text

“With  Google”   Devices that have “with Google” add-on feature a set of Google’s proprietary applications, such as Maps, Gmail, Gtalk, and many others. OEMs and carriers typically enter into a licensing agreement with Google in order to distribute Google version of Android.

Slide 12

Slide 12 text

ANDROID  STACK  

Slide 13

Slide 13 text

The  Stack   Linux Kernel Libraries Application Framework Applications Home Contacts Phone Browser Other Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notiication Manager Surface Manager OpenGL SGL Media Framework FreeType SSL SQLite WebKit libc Android Runtime Core Libs Dalvik VM Display Driver Keypad Driver Camera Driver WiFi Driver Flash Driver Audio Driver Binder Driver Power Mgmt

Slide 14

Slide 14 text

Linux  Kernel   Android runs on Linux. Linux provides: Hardware abstraction layer Memory management Process management Networking Users never see Linux sub system The adb shell command opens Linux shell Linux Kernel Libraries Application Framework Applications Home Contacts Phone Browser Other Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notiication Manager Surface Manager OpenGL SGL Media Framework FreeType SSL SQLite WebKit libc Android Runtime Core Libs Dalvik VM Display Driver Keypad Driver Camera Driver WiFi Driver Flash Driver Audio Driver Binder Driver Power Mgmt Android™ Stack

Slide 15

Slide 15 text

Na

Slide 16

Slide 16 text

Dalvik   Dalvik VM is Android implementation of Java VM Dalvik is optimized for mobile devices: •  Battery consumption •  CPU capabilities Key Dalvik differences: •  Register-based versus stack-based VM •  Dalvik runs .dex files •  More efficient and compact implementation •  Different set of Java libraries than JDK

Slide 17

Slide 17 text

Applica

Slide 18

Slide 18 text

Applica

Slide 19

Slide 19 text

App  Distribu

Slide 20

Slide 20 text

Markets   •  Google  Android  Market   •  Amazon  Android  Market   •  Other  emerging  markets  

Slide 21

Slide 21 text

Side  Loading  

Slide 22

Slide 22 text

Internal  App  Directory  

Slide 23

Slide 23 text

OPERATING  SYSTEM  FEATURES    

Slide 24

Slide 24 text

Mul

Slide 25

Slide 25 text

Supported  Media  Formats   Audio   AAC  LC/LTP,  HE-­‐AACv1  (AAC+),  HE-­‐ AACv2,  AMR-­‐NB,  AMR-­‐WB,  MP3,   MIDI,  RTTTL/RTX,  Ogg,  PCM/WAVE   Video   H.263,  H.264,  MPEG-­‐4,  VP8   Image   JPEG,  GIF,  PNG,  BMP   RTSP and HTTP progressive streaming. HTTP live streaming coming soon. More native support in the works. Native support available via Khronos OpenMax IL

Slide 26

Slide 26 text

Cloud  to  Device  Push   Big deal for many pull-based apps. Will make devices use less battery.

Slide 27

Slide 27 text

C2DM  –  The  Big  Picture  

Slide 28

Slide 28 text

Device  Administra

Slide 29

Slide 29 text

File  System   The file system has three main mount points. One for system, one for the apps, and one for whatever. Each app has its own sandbox easily accessible to it. No one else can access its data. The sandbox is in /data/data/com.marakana.yamba/ SDCard is expected to always be there. It’s a good place for large files, such as movies and music. Everyone can access it. System partition is where the entire Android operating system is, customized by OEM or not.

Slide 30

Slide 30 text

HELLO  WORLD!  

Slide 31

Slide 31 text

Android  SDK  -­‐  What’s  In  The  Box   SDK Tools Docs Platforms Data Skins Images Samples Add-ons Google

Slide 32

Slide 32 text

Create  New  Project   Use the Eclipse tool to create a new Android project. Here are some key constructs: Project   Eclipse  construct   Target   minimum  to  run   App  name   whatever   Package   Java  package   Ac

Slide 33

Slide 33 text

Anatomy   of  An  App   Java Code + XML and Other Resources + Manifest File = Android App

Slide 34

Slide 34 text

Running  on  Emulator   Emulator, not a simulator

Slide 35

Slide 35 text

MAIN  BUILDING  BLOCKS  

Slide 36

Slide 36 text

Yamba  Demo   Let’s see a real-world medium complexity Android app in action: Yamba: Yet Another Micro Blogging App

Slide 37

Slide 37 text

Ac

Slide 38

Slide 38 text

Ac

Slide 39

Slide 39 text

Intents   Intents represent events or actions. They are to Android apps what hyperlinks are to websites. Sort of. Intents can be implicit or explicit.

Slide 40

Slide 40 text

Services   Services are code that runs in the background. They can be started and stopped. Services doesn’t have UI.

Slide 41

Slide 41 text

Service  Lifecycle   Service also has a lifecycle, but it’s much simpler than activity’s. An activity typically starts and stops a service to do some work for it in the background, such as play music, check for new tweets, etc. Services can be bound or unbound.

Slide 42

Slide 42 text

Remote  Services  

Slide 43

Slide 43 text

Content  Providers   Content Providers share content with applications across application boundaries. Examples of built-in Content Providers are: Contacts, MediaStore, Settings and more.

Slide 44

Slide 44 text

Content  Provider  Example  

Slide 45

Slide 45 text

Broadcast  Receivers   An Intent-based publish-subscribe mechanism. Great for listening system events such as SMS messages.

Slide 46

Slide 46 text

Architecture  of  An  App   An Android application is a collection of many different building blocks. They are loosely coupled and can be reconfigured by the developer easily, or at least that’s the intention. Let’s look at 7 stages of Yamba next.

Slide 47

Slide 47 text

Yamba  Part  1  

Slide 48

Slide 48 text

Yamba  Part  2  

Slide 49

Slide 49 text

Yamba  Part  3  

Slide 50

Slide 50 text

Yamba  Part  4  

Slide 51

Slide 51 text

Yamba  Part  5  

Slide 52

Slide 52 text

Yamba  Part  6  

Slide 53

Slide 53 text

Yamba  Part  7  

Slide 54

Slide 54 text

ANDROID  USER  INTERFACE  

Slide 55

Slide 55 text

Two  UI  Approaches   Procedural   DeclaraKve   You  write  Java  code   Similar  to  Swing  or  AWT   You  write  XML  code   Similar  to  HTML  of  a  web  page   You can mix and match both styles. Best practice: •  Start with XML and declare most of UI •  Switch to Java and implement the UI logic

Slide 56

Slide 56 text

XML-­‐Based  User  Interface   Use WYSIWYG tools to build powerful XML-based UI. Easily customize it from Java. Separate concerns.

Slide 57

Slide 57 text

Views  and  Layouts   Layouts contain widgets and other layouts forming a “composite” pattern.

Slide 58

Slide 58 text

Linear  Layout   One of the most commonly used layouts. It lays its children next to each other, either horizontally or vertically.

Slide 59

Slide 59 text

Rela

Slide 60

Slide 60 text

Table  Layout   Table layout puts its children into table rows and columns. It is similar to an HTML table.

Slide 61

Slide 61 text

Frame  Layout   Frame layout places its children on top of each other, like a deck of cards. It is useful for widgets such as tabs or as a placeholder for views added programmatically.

Slide 62

Slide 62 text

Common  UI  Components   Android UI includes many common modern UI widgets, such as Buttons, Tabs, Progress Bars, Date and Time Pickers, etc.

Slide 63

Slide 63 text

Selec

Slide 64

Slide 64 text

Adapters   To make sure they run smoothly, Android uses Adapters to connect them to their data sources. A typical data source is an Array or a Database. Data Source Adapter

Slide 65

Slide 65 text

Complex  Components   Certain high-level components are simply available just like Views. Adding a Map or a Video to your application is almost like adding a Button or a piece of text.

Slide 66

Slide 66 text

Menus  and  Dialogs  

Slide 67

Slide 67 text

Graphics  &  Anima

Slide 68

Slide 68 text

Mul

Slide 69

Slide 69 text

DEBUGGING     ANDROID  APPS  

Slide 70

Slide 70 text

LogCat   The universal, most versatile way to track what is going on in your app. Can be viewed via command line or Eclipse. Logs can be generated both from SDK Java code, or low-level C code via Bionic libc extension.

Slide 71

Slide 71 text

Debugger   Your standard debugger is included in SDK, with all the usual bells & whistles.

Slide 72

Slide 72 text

TraceView   TraceView helps you profile you application and find bottlenecks. It shows execution of various calls through the entire stack. You can zoom into specific calls.

Slide 73

Slide 73 text

Hierarchy  Viewer   Hierarchy Viewer helps you analyze your User Interface. Base UI tends to be the most “expensive” part of your application, this tool is very useful.

Slide 74

Slide 74 text

ANDROID   SECURITY  

Slide 75

Slide 75 text

Security  Overview   No app can adversely impact other apps, user, or OS Cannot read/write user’s private data Cannot read other app’s data Cannot perform network access Cannot keep device awake, and so on Each application is its own sandbox To share resources, apps need to request permissions User must grant permissions at install time Linux manages security Not up to Dalvik (Java) but outsourced to Linux Native code (NDK) also adheres to sandboxing

Slide 76

Slide 76 text

Applica

Slide 77

Slide 77 text

Permissions   A component that does something potentially dangerous can require callers to have permission to access it. App that wants to use it must have user grant it permission. Permissions are granted at install time. All or nothing. Forever.

Slide 78

Slide 78 text

Some  System  Permissions   ACCESS_COARSE_LOCATION   ACCESS_FINE_LOCATION   ACCESS_NETWORK_STATE   ACCESS_WIFI_STATE   BATTERY_STATS   BLUETOOTH   CALL_PHONE   CALL_PRIVILEGED   CAMERA   DEVICE_POWER   GET_ACCOUNTS   GET_TASKS   INSTALL_PACKAGES   INTERNET   KILL_BACKGROUND_PROCESSES   NFC   READ_CALENDAR   READ_CONTACTS   RECEIVE_SMS   RECORD_AUDIO   WRITE_EXTERNAL_STORAGE   WRITE_SETTINGS  

Slide 79

Slide 79 text

Summary   Android is open and complete system for mobile development. It is based on Java and augmented with XML. It takes about 3-5 days of intensive training to learn Android application development for someone who has basic Java (or similar) experience. Marko Gargenta, Marakana.com [email protected] +1-415-647-7000