Introduction to Android Development

666 views
567 views

Published on

"Understanding Android" - On Ramp's presentation at the GDG BarCamp Addis Ababa 27th April 2013. An introduction to Android application development.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
666
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
26
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to Android Development

  1. 1. Presented by On RampAndroidDo Androids dream of electric sheep?Understanding the Android platformA developers perspective
  2. 2. 1 May 2013 Presented by On RampPresented by On RampObjectiveProvide a high level conceptualmodel for understanding how tobuild Android Applications
  3. 3. 1 May 2013 Presented by On RampPresented by On RampAbout Me● South African open source solutions integrator,– Java developer,– Drupal developer,– Loves Linux,● On Ramp– Ethiopian Company● Linux, Java, Android training and development house●Specialising in mobile telecoms space
  4. 4. 1 May 2013 Presented by On RampPresented by On RampAgenda● Android Architecture● Supported Languages● Dalvik VM● Development Environments● Components – Building Blocks● High Level Overview
  5. 5. 1 May 2013 Presented by On RampPresented by On RampAgenda● Important concepts– Intents– Activities, Services, ContentProviders & Broadcast Receivers– Resources
  6. 6. 1 May 2013 Presented by On RampPresented by On RampWhat isAndroid?Android is a software stack formobile devices that includes anoperating system, middleware andkey applications
  7. 7. 1 May 2013 Presented by On RampPresented by On RampArchitecture
  8. 8. 1 May 2013 Presented by On RampPresented by On RampArchitecture● Linux Layer– Based on Linux,– Source now part of mainline LinuxV3.3– Linux security, processmanagement & networking
  9. 9. 1 May 2013 Presented by On RampPresented by On RampArchitecture● Linux Layer– Each app has its own Linux user,– All files and resources owned byapp user,– Other processes, app cannotaccess other apps files/resources
  10. 10. 1 May 2013 Presented by On RampPresented by On RampArchitecture● Core libraries written in C/C++– Android runtime – Dalvik– Services exposed via applicationlayer,– Reuses open source components –SQLite, FreeType etc
  11. 11. 1 May 2013 Presented by On RampPresented by On RampArchitecture● Framework layer– What your application interactswith,– API calls to framework services,– Key concepts to grok Android API
  12. 12. 1 May 2013 Presented by On RampPresented by On RampArchitectureYOU!● Applicationwritten to useservices of the Androidplatform
  13. 13. 1 May 2013 Presented by On RampPresented by On RampSupportedLanguages● Android applications can bewritten in– Java● Supports a subset of Java API,● Can use most Java libraries,– C/C++ using nativedevelopment kit● Should only be whenperformance is an issue.
  14. 14. 1 May 2013 Presented by On RampPresented by On RampSupportedLanguages– C/C++ using native development kit● Used to write components called fromJava
  15. 15. 1 May 2013 Presented by On RampPresented by On RampSupportedLanguages● Second Class Citizens– Scripting languages via ScriptingLayer for Android– Javascript, Ruby, Python,LUA, Perl– HTML 5 Apps● Important – Phonegap etc
  16. 16. 1 May 2013 Presented by On RampPresented by On RampDalvik● Dalvik is a processvirtual machine– Application written inJava– Complied to Java bytecode (.class files)– Converted into Dalvikcompatible files (.dex)when packaged
  17. 17. 1 May 2013 Presented by On RampPresented by On RampDalvik● Why Dalvik?– More compact & memory efficientthan .class files– Each application runs in its ownprocess,– Each process gets it own VM– Packaging (apk) files are zipped.dex files
  18. 18. 1 May 2013 Presented by On RampPresented by On RampDevelopmentEnvironments● Android SDK,– Debugger● (ADB – Andorid Debugger Bridge)– Libraries– Emulator● Supported IDE – Eclipse– ADT plugin
  19. 19. 1 May 2013 Presented by On RampPresented by On RampDevelopmentEnvironments● Other IDE support– NetBeans– IntelliJ– Command line/text editor● Build tool– Ant (official)
  20. 20. 1 May 2013 Presented by On RampPresented by On RampDevelopmentEnvironments● Build tool– Maven (support fromspringsource)● Android applications havea directory structure– Naming of directories isimportant especially forresources
  21. 21. 1 May 2013 Presented by On RampPresented by On RampCoreComponents● Activities– UI Layer– Similar to UI controller for web apps● Services– Provides services to other applications, no ui, run inbackground● Content Providers– Used to pass information between applications● Broadcast receivers– Listen to system events and broad cast and react
  22. 22. 1 May 2013 Presented by On RampPresented by On RampCoreComponents● Notifications– System notifications
  23. 23. 1 May 2013 Presented by On RampPresented by On RampHigh LevelOverview● Different from web or desktopapplications,● Android in control of/managesapplication,– Constrained environment,– Memory management,– Power usage etc
  24. 24. 1 May 2013 Presented by On RampPresented by On RampHigh LevelOverview● Components interact with oneanother indirectly.● Android controls creation, lifecycle of components
  25. 25. 1 May 2013 Presented by On RampPresented by On RampHigh LevelUnderstanding● Applications can use componentsfrom other apps,● Task Stack -– Android places UI components(Activities), maybe from differentapps, onto a task stack, as usernavigates through an application
  26. 26. 1 May 2013 Presented by On RampPresented by On RampHigh LevelOverview● Component life cycle controlled byplatform,● Platform provides life cycle methods toallow components to react to changes inlife cycle– onStart– onResume– onPause etc
  27. 27. 1 May 2013 Presented by On RampPresented by On RampHigh LevelOverview● Activity 2 & Activity 3 may befrom different applicationsTask Stack
  28. 28. 1 May 2013 Presented by On RampPresented by On RampHigh LevelOverview● How does your activity requestnew component from Android?– API calls– Via Intents● Define what you would like to havehappen next,● Pass data to next activity● Receive data back
  29. 29. 1 May 2013 Presented by On RampPresented by On RampIntents● Intents– can be specific -i.e require specificclass or– Ask for any activity that providesrequired service● e.g view web page
  30. 30. 1 May 2013 Presented by On RampPresented by On RampIntents● Intent made up of– Action: view web page,place call– Category: what attribute thecomponent must have for youraction e.g must display homescreen– Extra: data to pass betweencomponents
  31. 31. 1 May 2013 Presented by On RampPresented by On RampComponentsData Sharing● How do components pass databetween each other?– Bundles/Extra = can add data thatneeds to be transferred with Intent
  32. 32. 1 May 2013 Presented by On RampPresented by On RampSummaryUIcomponentsbelong to ataskPlatform createscomponents onyou behalfAPI used torequestcomponentcreationComponentshave a lifecycleComponentsare buildingblocks foryour appOther appsmay useyourcomponents
  33. 33. 1 May 2013 Presented by On RampPresented by On RampAndroidWhere to start?Start coding Activity components
  34. 34. 1 May 2013 Presented by On RampPresented by On RampActivities● Main entry point for application,● Configures user interface andhandles events,● Each activity has one window inwhich to draw,
  35. 35. 1 May 2013 Presented by On RampPresented by On RampActivities● UI layout is best done with xmlresource files,● Java code for handling events &setting up UI● UI widgets extend View class– Views are the display classes usedby an activity
  36. 36. 1 May 2013 Presented by On RampPresented by On RampActivity UILayout●ADT plugin provides designer● Similar to XHTM:
  37. 37. 1 May 2013 Presented by On RampPresented by On RampActivityLifecycle
  38. 38. 1 May 2013 Presented by On RampPresented by On RampActivitiesScreen Flow● Flow between activities orscreens is not direct,● Application framework handlesthis for you● You ask framework to createnext screen you wish to display
  39. 39. 1 May 2013 Presented by On RampPresented by On RampActivitiesScreen Flow● API Calls -– startActivity(Intent)– startActivityForResult(Intent)
  40. 40. 1 May 2013 Presented by On RampPresented by On RampResources● Resources are static content● Resources are managed bygenerated code● Layout definitions● Images● String constants● Resource ids
  41. 41. 1 May 2013 Presented by On RampPresented by On RampResources● Resources are defined in● xml files,● Images in folders– Resources directory = res– Naming of directories is important
  42. 42. 1 May 2013 Presented by On RampPresented by On RampApplicationConfiguration● Applications are groupings ofcomponents– Activities,– Services– Broadcast receivers– Content provider
  43. 43. 1 May 2013 Presented by On RampPresented by On RampApplicationConfiguration● Apps are defined via manifest.xml– <application> defines● launcher activity for app,● what intents your components are created tohandle– <uses-permission> to identify what servicesyour application requires access to
  44. 44. 1 May 2013 Presented by On RampPresented by On RampSecurity● Linux layer– process level security,– File level security● Application layer– Request permission from user toaccess services– manifest.xml <use-permission>
  45. 45. 1 May 2013 Presented by On RampPresented by On RampContact Info● On Ramp Web Site– http://www.onramp.mobi● Social Networks -– Twitter @mxc4– G+ MClarke4● Email:– support@onramp.mobi– mark@onramp.mobi

×