Successfully reported this slideshow.

Android: A 9,000-foot Overview


Published on

Android Overview presentation, given by Marko Gargenta at IEEE in Sunnyvale, CA in April 2010.

Published in: Technology
  • Be the first to comment

Android: A 9,000-foot Overview

  1. 1. Android:     A  9,000-­‐foot   Overview   Marko  Gargenta   Marakana  
  2. 2. Agenda   •  Android  History   •  Android  and  Java   •  The  Stack   •  Android  SDK   •  Hello  World!   •  Main  Building  Blocks   •  Android  User  Interface   •  Debugging   •  Summary  
  3. 3. History   2005   Google  buys  Android,  Inc.   Work  on  Dalvik  starts   2007   OHA  Announced   Early  SDK   2008   G1  Announced   SDK  1.0  Released   2009   G2  Released   Cupcake,  Donut,  Eclair  
  4. 4. Android  and  Java   Android Java = Java SE – AWT/Swing + Android API
  5. 5. ANDROID  STACK  
  6. 6. The  Stack  
  7. 7. Linux  Kernel   Android runs on Linux. Applications Home Contacts Phone Browser Other Linux provides as well as: Hardware abstraction layer Application Framework Memory management Activity Window Content View Process management Manager Manager Providers System Package Telephony Resource Location Notiication Networking Manager Manager Manager Manager Manager Libraries Users never see Linux sub system Surface Media SQLite Android Runtime Manager Framework Core Libs The adb shell command opens OpenGL FreeType WebKit Delvik Linux shell SGL SSL libc VM Display Camera Linux Kernel Flash Binder Driver Driver Driver Driver Keypad WiFi Audio Power Driver Driver Driver Mgmt
  8. 8. NaXve  Libraries   Bionic, a super fast and small Applications license-friendly libc library Home Contacts Phone Browser Other optimized for embedded use Application Framework Surface Manager for composing Activity Window Content View window manager with off-screen Manager Manager Providers System buffering Package Telephony Resource Location Notiication Manager Manager Manager Manager Manager Libraries 2D and 3D graphics hardware Surface Media SQLite Android Runtime support or software simulation Manager Framework Core Libs OpenGL FreeType WebKit Delvik Media codecs offer support for SGL SSL libc VM major audio/video codecs Display Camera Linux Kernel Flash Binder Driver Driver SQLite database Driver Driver Keypad WiFi Audio Power Driver Driver Driver Mgmt WebKit library for fast HTML rendering
  9. 9. Dalvik   Dalvik VM is Google’s implementation of Java Optimized for mobile devices Key Dalvik differences: Register-based versus stack-based VM Dalvik runs .dex files More efficient and compact implementation Different set of Java libraries than SDK
  10. 10. ApplicaXon  Framework   Activation manager controls the life Applications cycle of the app Home Contacts Phone Browser Other Content providers encapsulate data Application Framework that is shared (e.g. contacts) Activity Window Content View Manager Manager Providers System Package Telephony Resource Location Notiication Resource manager manages Manager Manager Manager Manager Manager everything that is not the code Libraries Surface Media SQLite Android Runtime Manager Framework Location manager figures out the Core Libs location of the phone (GPS, GSM, OpenGL FreeType WebKit Delvik WiFi) SGL SSL libc VM Notification manager for events Display Driver Camera Driver Linux Kernel Flash Driver Binder Driver such as arriving messages, Keypad WiFi Audio Driver Power Mgmt Driver Driver appointments, etc
  11. 11. ApplicaXons   Dalvik Executable + Resources = APK Must be signed (but debug key is okay for development) Many markets with different policies
  12. 12. Android  SDK  -­‐  What’s  in  the  box   SDK Tools Docs Platforms Data Skins Images Samples Add-ons Google Maps
  13. 13. The  Tools   Tools are important part of the SDK. They are available via Eclipse plugin as well as command line shell.
  14. 14. HELLO  WORLD!  
  15. 15. 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   AcXvity   Java  class  
  16. 16. The  Manifest  File   <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="" package="com.marakana" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="5" /> </manifest>
  17. 17. The  Layout  Resource   <?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" android:text="@string/hello" /> </LinearLayout>
  18. 18. The  Java  File   package com.marakana; import; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
  19. 19. Running  on  Emulator  
  21. 21. AcXviXes   Activity is to an Android Application application what a Main Activity Another Another Activity Activity web page is to a website. Sort of.
  22. 22. AcXvity  Lifecycle   Starting Activities have a well- (1) onCreate() (2) onStart() (3) onRestoreInstanceState() defined lifecycle. The (4) onResume() Android OS manages your activity by Running changing its state. (3) onResume() (2) onStart() (1) onSaveInstanceState() (2) onPause() You fill in the blanks. (1) onRestart() onResume() (1) onSaveInstanceState() Stopped (2) onStop() Paused onDestroy() or <process killed> <process killed> Destroyed
  23. 23. Intents   Intents are to Android Application Android apps Another Main Activity Intent what hyperlinks Activity are to websites. They can be Intent implicit and Android Application explicit. Sort of like absolute and Main Activity Intent Another Activity relative links.
  24. 24. Services   A service is something that can be started and stopped. It doesn’t have UI. It is typically managed by an activity. Music player, for example
  25. 25. Service  Lifecycle   Service also has a Starting lifecycle, but it’s (1) onCreate() much simpler than (2) onStart() activity’s. An activity onStart() typically starts and stops a service to do Stopped Running some work for it in the background. onStop() Such as play music, check for new onDestroy() or tweets, etc. <process killed> Destroyed
  26. 26. Content  Providers   Content Providers share Content content with applications Provider across application Content URI boundaries. insert() Examples of built-in update() Content Providers are: delete() Contacts, MediaStore, query() Settings and more.
  27. 27. Broadcast  Receivers   An Intent-based publish-subscribe mechanism. Great for listening system events such as SMS messages.
  29. 29. Two  UI  Approaches   Procedural   Declara?ve   You  write  Java  code   You  write  XML  code   Similar  to  Swing  or  AWT   Similar  to  HTML  of  a  web  page   You can mix and match both styles. Declarative is preferred: easier and more tools
  30. 30. XML-­‐Based  User  Interface   Use WYSIWYG tools to build powerful XML-based UI. Easily customize it from Java. Separate concerns.
  31. 31. Dips  and  Sps   px  (pixel)   Dots  on  the  screen   in  (inches)   Size  as  measured  by  a  ruler   mm  (millimeters)   Size  as  measured  by  a  ruler   pt  (points)   1/72  of  an  inch   dp  (density-­‐independent  pixel)   Abstract  unit.  On  screen  with  160dpi,   1dp=1px   dip   synonym  for  dp  and  oeen  used  by  Google   sp   Similar  to  dp  but  also  scaled  by  users  font   size  preference  
  32. 32. Views  and  Layouts   ViewGroup ViewGroup View View View View ViewGroups contain other Views but are also Views themselves.
  33. 33. Common  UI  Components   Android UI includes many common modern UI widgets, such as Buttons, Tabs, Progress Bars, Date and Time Pickers, etc.
  34. 34. SelecXon  Components   Some UI widgets may be linked to zillions of pieces of data. Examples are ListView and Spinners (pull-downs).
  35. 35. Adapters   Adapter Data Source 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.
  36. 36. 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.
  37. 37. Menus  and  Dialogs  
  38. 38. Graphics  &  AnimaXon   Android has rich support for 2D graphics. You can draw & animate from XML. You can use OpenGL for 3D graphics.
  39. 39. MulXmedia   AudioPlayer lets you simply specify the audio resource and play it. VideoView is a View that you can drop anywhere in your activity, point to a video file and play it. XML: <VideoView android:id="@+id/video" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center” /> Java: player = (VideoView) findViewById(; player.setVideoPath("/sdcard/samplevideo.3gp"); player.start();
  40. 40. Google  Maps   Google Maps is an add-on in Android. It is not part of open-source project. However, adding Maps is relatively easy using MapView. XML: < android:id="@+id/map" android:clickable="true" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="0EfLSgdSCWIN…A" />
  42. 42. 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.
  43. 43. Debugger   Your standard debugger is included in SDK, with all the usual bells & whistles.
  44. 44. 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.
  45. 45. 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.
  46. 46. Summary   Android is based on Java. You write Java code, but technically don’t run it. Java is augmented with XML, mostly for UI purposes. Android Java is mostly based on Java SE with replacement UI libraries. Marko Gargenta, +1-415-647-7000 Licensed under Creative Commons License (cc-by-nc-nd). Please Share!