Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Android


Published on

Introduction to Android

By Eng.Ahmed Mustafa Daoud

At Google Camp event

Organized by MUFIX Community

Published in: Education, Technology
  • Be the first to like this

Introduction to Android

  1. 1. A Developer’s Introduction toMobile computing &Google Android Dr. Frank McCown Harding University Fall 2011 Edited by Ahmed Daoud This work is licensed under Creative Commons Attribution-NonCommercial 3.0
  2. 2. Why Mobile Computing? • Mobile platform is the platform of the future – Double-digit growth in world-wide smartphone ownership3 • Job market is hot – Market for mobile software surges from $4.1 billion in 2009 to $17.5 billion by 20121 – 2010 survey: 72% of recruiters looking for iPhone app developers, 60% for Android1 – mobile app developers made $85,000 in 2010 and salaries expected to rise2 • It’s a lot of fun!1 23
  3. 3. Smartphones BlackBerryiPhone 4 LG Revolution HTC Trophy Curve 3
  4. 4. 4
  5. 5. TabletsGalaxy Tab 10.1 Acer Iconia Tab W500 iPad 2 5
  6. 6. Device Usage 6
  7. 7. Smartphone vs. PC Sales 7
  8. 8. Smartphone Market Share 8
  9. 9. Top US Smartphone OS Platforms 9
  10. 10. Mobile Devices: Advantages• Always with the user• Typically have Internet access• Typically GPS enabled• Typically have accelerometer & compass• Typically have cameras & microphones• Apps are free or low-cost 10
  11. 11. Mobile Devices: Disadvantages• Limited screen size• Limited battery life• Limited processor speed• Limited and sometimes slow network access• Limited or awkward input: soft keyboard, phone keypad, touch screen, or stylus• Limited web browser functionality• Range of platforms & configurations across devices 11
  12. 12. Mobile Applications• What are they? – Any application that runs on a mobile device• Types – Web apps: run in a web browser • HTML, JavaScript, Flash, server-side components, etc. – Native: compiled binaries for the device• Economics – Free (often ad-supported) vs. paid 12
  13. 13. Free vs. Paid Apps 13
  14. 14. Popular Development Environments• Java ME• .NET Compact Framework (C++, C#, VB.NET) for Windows Mobile• Windows Phone 7 (Silverlight and XNA)• Qualcomm’s BREW (C or C++)• Symbian (C++)• BlackBerry (Java)• Android (Java)• iPhone (Objective-C)• Is having so many choices a good thing? 14
  15. 15. xCode IDE & iPhone Emulator 15
  16. 16. Eclipse and Android Emulator 16
  17. 17. Brief History• 2005 – Google acquires startup Android Inc. to start Android platform – Work on Dalvik VM begins• 2007 – Open Handset Alliance announced – Early look at SDK• 2008 – Google sponsors 1st Android Developer Challenge – T-Mobile G1 announced – SDK 1.0 released – Android released open source (Apache License) – Android Dev Phone 1 released Pro Android by Hashimi & Komatineni (2009) 17
  18. 18. Brief History cont.• 2009 – SDK 1.5 (Cupcake) • New soft keyboard with “autocomplete” feature – SDK 1.6 (Donut) • Support Wide VGA – SDK 2.0/2.0.1/2.1 (Eclair) • Revamped UI, browser• 2010 – Nexus One released to the public – SDK 2.2 (Froyo) • Flash support, tethering – SDK 2.3 (Gingerbread) • UI update, system-wide copy-paste 18
  19. 19. Brief History cont.• 2011 – SDK 3.0 (Honeycomb) for tablets only • New UI for tablets, support multi-core processors – SDK 3.1 and 3.2 • Hardware support and UI improvements – SDK 4.0 (Ice Cream Sandwich) • For Q4, combination of Gingerbread and Honeycomb 19
  20. 20.
  21. 21. What is Google Android?• A software stack for mobile devices that includes – An operating system – Middleware – Key Applications• Uses Linux to provide core system services – Security – Memory management – Process management – Power management – Hardware drivers
  22. 22.
  23. 23. Setup Development Environment• Install JDK 5, 6, or 7• Install Eclipse IDE for Java EE Developers (version 3.7 - Indigo)• Download and unpack the Android SDK• Install Android Development Tools (ADT) plugin for Eclipse• Detailed install instructions available on Android site
  24. 24. 24
  25. 25. Android Emulator or AVD• Emulator is essential to testing app but is not a substitute for a real device• Emulators are called Android Virtual Devices (AVDs)• Android SDK and AVD Manager allows you to create AVDs that target any Android API level• AVD have configurable resolutions, RAM, SD cards, skins, and other hardware 25
  26. 26. Android Emulator: 1.6 Device 26
  27. 27. Android Emulator: 2.2 Device 27
  28. 28. Android Emulator: 3.0 Device 28
  29. 29. Emulator Basics• Host computer’s keyboard works• Host’s mouse works like finger• Uses host’s Internet connection• Side buttons work: Home, Menu, Back, Search, volume up and down, etc.• Ctrl-F11 toggle landscape  portrait• Alt-Enter toggle full-screen mode• More info at 29
  30. 30. Emulator Limitations• No support for placing or receiving actual phone calls – Simulate phone calls (placed and received) through the emulator console• No support for USB connections• No support for camera/video capture (input)• No support for device-attached headphones• No support for determining connected state• No support for determining battery charge level and AC charging state• No support for determining SD card insert/eject• No support for Bluetooth• No support for simulating the accelerometer – Use OpenIntents’s Sensor Simulator 30
  31. 31. In other words,test your app onan actual device! 31
  32. 32. Create an AVD usingAndroid SDK and AVD Manager 32
  33. 33. Or From the Command LineC:android-sdk-windowstools>android create avd -n MyDevice -t android-8Android 2.2 is a basic Android platform.Do you wish to create a custom hardware profile [no]Created AVD MyDevice2 based on Android 2.2, Device namewith the following hardware config: Target platformhw.lcd.density=240vm.heapSize=24C:android-sdk-windowstools>emulator -avd MyDevice Launch device More info: 33
  34. 34. Android Runtime: Dalvik VM• Subset of Java developed by Google• Optimized for mobile devices (better memory management, battery utilization, etc.)• Dalvik runs .dex files that are compiled from .class files• Introduces some new libraries• Does not support some Java libraries like AWT
  35. 35. Applications Are Boxed• By default, each app is run in its own Linux process – Process started when app’s code needs to be executed – Threads can be started to handle time-consuming operations• Each process has its own Dalvik VM• By default, each app is assigned unique Linux ID – Permissions are set so app’s files are only visible to that app
  36. 36. Producing an Android App javacJava code Byte code dx .java .class Dalvik exe classes.dex aapt Byte code <xml> Other .class files AndroidManifest.xml .apk <str> Resources
  37. 37. Hello Android Tutorial
  38. 38. Important Files• src/ – Activity which is started when app executes• res/layout/main.xml – Defines & lays out widgets for the activity• res/values/strings.xml – String constants used by app• gen/ (Don’t touch!) – Auto-generated file with identifiers from main.xml, strings.xml, and elsewhere• AndroidManifest.xml – Declares all the app’s components – Names libraries app needs to be linked against – Identifies permissions the app expects to be granted 38
  39. 39. src/• Activity which is started when app executes 39
  40. 40. res/layout/main.xml• Declares layouts & widgets for the activity Tree from: 40
  41. 41. Various Layouts 41
  42. 42. Various Widgets 42
  43. 43. res/values/strings.xml• String constants used by app• Used for supporting Localization – res/values-es/values/strings.xml to support Spanish – res/values-fr/values/strings.xml to support French – Etc. 43
  44. 44. gen/• Auto-generated file with identifiers from main.xml, strings.xml, and elsewhere Do not modify! 44
  45. 45. AndroidManifest.xml• Declares all the app’s components• Names libraries app needs to be linked against• Identifies permissions the app expects to be granted 45
  46. 46. Four Application Components1. Activities – Presents a visual UI for a single endeavor – Single app may be composed of several activities – Examples: list of photos, buttons to start/stop a song2. Services – Performs background work (no UI) – Examples: play background music, retrieve data over a network3. Broadcast Receivers – Receives and reacts to broadcast announcements (no UI) – Broadcast examples: battery is low, pic is taken, lang pref changed4. Content Providers – Provides app data to other applications (no UI) – Examples: share contact info from SQLite, image from the file system 46
  47. 47. SDK Samples
  48. 48. Activity Lifecycle
  49. 49. Thank youAny Question?
  50. 50. References• Android Introduction by Marko Gargenta, oid-software-platform/• Android Dev Guide ndamentals.html• Pro Android by Hashimi & Komatineni (2009)