NoZoM Android Workshop

download NoZoM Android Workshop

of 47

Transcript of NoZoM Android Workshop

  • 7/31/2019 NoZoM Android Workshop

    1/47

    Getting started with AndroidIntroduction to android application developmentsession by

    By @AlSayedGamal

    #Nozom_android

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    2/47

    Agenda

    Whats Android.The stack.

    android Roadmap.

    Getting your hands dirty.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    3/47

    1.Whats Android and whats not?

    Android is

    for

    that

    includes an operating system, middleware and kepapplications.

    Its NOT a handset name.

    ItsNOT

    J2ME.Its NOT Google reply to iPhone.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    4/47

    History

    Aug 2005

    Google acquired Android.

    Nov 2007

    OHA* announced that Android SDK is available.

    Sept 2008

    HTC and T-Mobile announced G1

    Oct 2008

    Android SDK 1.0

    Android Market goes live

    G1 is available in the retail store.

    *OHA is (Open Handset Alliance) including top OEM and operators {Motorolla, intel, htc, T-Mobile, Samsung, LG, Google, etc..

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    5/47

    OHA

    pen

    andset

    lliance

    OEM

    Semi-conductors

    Commercialization

    Software

    operator

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    6/47

    Dec 2011

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    7/47

    OS Shares worldwide*

    Android Symbian

    iOS RIM

    Bada Microsoft

    Others

    *According to Gartner Nov 2011Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    8/47

    OS Shares worldwide*

    52%

    17%

    15%

    11%

    2%

    1%1%

    Android Symbian

    iOS RIM

    Bada Microsoft

    Others

    *According to Gartner Nov 2011Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    9/47

    Devices (not telephones)

    CellphonesTablets

    TV

    more

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    10/47

    2.The stackWhat to expect from android.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    11/47

    2.The stack.

    Android is based on the almighty linux kernel.

    Android comes with great libraries and APIs for your

    special hardware to make full use of you device.

    Android has rich development tool set including

    emulator, debugging tools, GUI composer,etc..

    Android is ready for i18n.

    The DVM is young VM yet its optimized to the linux

    kernel.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    12/47

    Technical prerequisites for

    Android development.

    Java* = Java SE - Swing - AWT - reflection + some API(s).

    HTML5 is an option (nice option if you are going cross platform).

    Others (nice for RAD and cross platform).

    *We are interested in that option todaySaturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    13/47

    Android the platform

    Android the OS is the largest part but its not

    everything.

    Android emulator and AVD.

    DVM (Dalvik Virtual Machine).

    ADB (Android Debug Bridge).

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    14/47

    Closer look

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    15/47

    Closer look

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    16/47

    Android internals

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    17/47

    Android internals

    Linux Kernel

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    18/47

    Android internals

    Linux Kernel

    Libraries

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    19/47

    Android internals

    Linux Kernel

    Libraries Android Runtime

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    20/47

    Android internals

    Linux Kernel

    Libraries Android Runtime

    Application Framework

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    21/47

    Android internals

    Linux Kernel

    Libraries Android Runtime

    Application Framework

    Applications

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    22/47

    Everything is an application

    Your app is first class citizen

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    23/47

    API levels and Android versions.

    You must have heard about Ice cream sandwich.

    API levels 1->14

    Android versions 1.x.x -> 4.x.x

    The capabilities vs. popularity compromise.

    Backward compatibility.

    A-[I]-Z.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    24/47

    Android development tools

    Eclipse ADT plugin

    DDMS

    AVD

    more..

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    25/47

    3.android RoadmapMilestones in any android developer life.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    26/47

    Rules are made to break in.

    Installation and configuration

    Activity and Intent

    Layouts

    Background Services

    Broadcast receivers.

    Content providers.

    Shared preferences, sqlite database and file storage.

    Internet and C2DM.

    Geolocation apps.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    27/47

    1.Activity

    publicclassActivityextendsApplicationContext{ protectedvoid onCreate(Bundle savedInstanceState); protectedvoid onStart();

    protectedvoid onRestart();

    protectedvoid onResume(); protectedvoid onPause(); protectedvoid onStop(); protectedvoid onDestroy();}

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    28/47

    1.Activity

    Activity class is the main building block in any android

    application.

    Basically every screen in any android app is an activity.

    Every activity may deal with one or more layout.

    Its essential to know the Activity lifecycle*.

    onCreate, onPause, onRestart, onResume methods.

    *Template design pattern.[2]Saturday, May 12, 12

    A d id A i i lif l

  • 7/31/2019 NoZoM Android Workshop

    29/47

    Android Activity lifecycle

    Image source: http://developer.android.com/images/activity_lifecycle.pngSaturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    30/47

    2.Intent

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    31/47

    2.Intent

    Intent is the message passing system in Android.

    Is used to message {activities, services and broadcast

    receivers}

    Its used to call system services as well as your app

    activities.*

    Intents can contain extra data and this is how wetransfer data between activities,apps,services,etc..

    Application dependency issues.

    *Thats why your app is 1st class citizen.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    32/47

    Intent filters

    When intents meet Activities.

    Action

    Category

    Ex.The application launcher scenario.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    33/47

    3.AndroidManifest.xml

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    34/47

    3.manifest.xml

    Each application has one manifest file

    Its app configuration file in short.

    ADT interface shows what do you expect from it.

    Warning: Dont forget to define your activies there.

    *Thats why your app is 1st class citizen.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    35/47

    4.Getting your hands dirtyLets practice what we have learnt so far.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    36/47

    1.Installation and

    configurationEclipse, ADT and the SDK

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    37/47

    Application Directory

    Structuresrc : your code lives here.

    res : your layout and resource files are here.

    gen: by name its generated content mostly it maps to

    layouts and resources.

    bin : output files and APK (Android Package)

    executable file.

    AndroidManifest.xml: general configuration file.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    38/47

    The Android Package

    meet the

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    39/47

    The Android Package

    APKmeet theSaturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    40/47

    The APK

    |--AndroidManifest.xml |-- META-INF | |-- CERT.RSA | |-- CERT.SF

    |

    `-- MANIFEST.MF |-- classes.dex |-- res | |-- drawable | | `-- icon.png | `-- layout

    |

    `-- main.xml `-- resources.arsc

    file.apk

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    41/47

    App1: todo list

    In order to add a new task as a user, I should be able

    to supply task name in a textbox and hit save.

    In order to confirm saving the task I should see a

    success message.

    Task should be added to a list of checkboxes.

    In order to mark a task completed I should check the

    check box by the task name.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    42/47

    App2:

    SuperComm

    App is basically 3 buttons using which user can accessdialer, SMS app, and web.

    App is containing a textbox containing the number/url

    Im trying to call,SMS or browse.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    43/47

    Debugging your app.

    DDMS.

    adb.

    file browser.

    Playing with the emulator.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    44/47

    References

    .

    Saturday, May 12, 12

    http://en.wikipedia.org/wiki/Template_method_patternhttp://en.wikipedia.org/wiki/Template_method_patternhttp://en.wikipedia.org/wiki/Template_method_patternhttp://en.wikipedia.org/wiki/Template_method_patternhttp://developer.android.com/http://developer.android.com/
  • 7/31/2019 NoZoM Android Workshop

    45/47

    Summary

    Android is now and future.

    Its opensource and fun.

    Android stack and rich development tools.

    Everything is an application and your application is 1st

    class citizen.

    Android application development terminology.

    Android development road map.

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    46/47

    Questions & Answers

    Saturday, May 12, 12

  • 7/31/2019 NoZoM Android Workshop

    47/47

    Thank you!