Your SlideShare is downloading. ×
  • Like
UCD Android Workshop
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

UCD Android Workshop


This is a presentation I gave to a workshop I organized in UCD focused on Android. …

This is a presentation I gave to a workshop I organized in UCD focused on Android.

The talk is divided into two sections:
- Android 101
- My experience trying to put together a facebook/foursquare/android mobile app
-- I did not progress very far in this endeavour

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • G1 –oct 08Sdk 1.1 – Jan 091.5 – apr 091.6 – sept 092.0 – dec 092.1 – jan 10
  • Services have lifetimes, but they are not as interesting


  • 1. Android Workshop
    UCD, 10th April 2010
  • 2. Objectives
    Android 101
    Overview of the platform
    Some market information
    Development of Android based app
    Partial Walkthrough
    Two components:
    Server side
    Facebook, foursquare
    Mobile client
    Talks to server (or not!)
  • 3. Android 101
  • 4. Overview
    Android concepts
    Comments on APIs
    Comment on market
  • 5. Background/History
    Android Inc developed vision for platform
    Acquired in 2005 by Google
    Launched November 2007
    In conjunction with Open Handset Alliance
    Number of variants since
    1.1, 1.5, 1.6, 2.0, 2.1
    Google working with many handset manufacturers and operators
    HTC, Sony Ericsson, Motorola, LG
  • 6. What is Android?
    Mobile Operating system
    Linux kernel v2.6.x
    Architecture for developing mobile applications
    Much work on developing concepts
    Mobile OS differs from desktop OS
    Large set of APIs
    Much functionality provided
    Dalvik VM
    Native Interface available late 09
  • 7. Differences from THE OTHER ONE
    More open in general
    Although key parts kept closed
    No constraints on store…
    Except that they pay store is not available in Ire
    Until last Thurs
    Issues with multi-touch until recently
  • 8. Perspective of App Developer
    Rich Java based framework
    Closer to Java SE than Java ME
    Good separation of UI and functionality
    Rapidly evolving platform
    Too fast in 09
    Platform with rapidly growing user base
    Rapidly increasing number of apps
    Do not have Apple toll bridge
    Anything can be published
  • 9. What does Android app look like
    Set of Java classes
    External jars need to be packaged
    Manifest describing application
    XML based descriptors of UI
    Packaged into apk file
    For distribution in market and more generally
    Can be signed
  • 10. Components
    Application comprised of different components
    Android defines 4 types of components
    Broadcast receivers
    Content providers
    Somehow notion of main not always necessary
    When writing a service, for example
  • 11. Activity
    Idea is somehow single action user is engaged in
    Part of a task
    Choosing people from list of contact
    Entering some text
    Navigating around a map
    Application can comprise of one or more activities
    Typically more
    One activity initiates next activity
  • 12. Activity
    Activities linked to views (somewhat)
    Android facilitates views which are decoupled
    Defined in XML and bundled with package
    Activity generally renders a specific view
    View designed for specific activity
  • 13. Services
    Like daemons
    Run for some period of time providing service for activities
    Fetch network data or perform calculation
    Music playback
    Service runs in main thread
    Can initiate other threads if needed
    Can bind to running service
  • 14. Broadcast receivers and Content Providers
    Broadcast receivers
    Listen for broadcast messages
    Time change, language change
    Do not have UI, but may engage with user
    Notification mechanism
    Can start activty
    Content Provider
    Enables an application to share its own data with another application
  • 15. Definition of the application – manifest.xml
    Every application has file defining components
    Lists activities, services, etc
    <?xml version="1.0" encoding="utf-8"?>
    <manifest . . . >
    <application . . . >
    <activity android:name="com.example.project.FreneticActivity"
    . . . >
    . . .
  • 16. Intents
    More complex (subtle?) notion
    Application can be invoked with different intents
    Eg from windows – file dragged onto app
    Behaviour of application depends on intent
    ACTION_MAIN most commonly used
    Manifest indicates which activity initiated on ACTION_MAIN
  • 17. Tasks
    Activities from multiple applications can be combined into tasks
    Applications can be aware of activities extant in other applications
    Can invoke them with certain intent
    Typically such activities in a ‘suite’
    A stack which retains user’s sequence of activities
    This is how user perceives application
    Note: application now ambiguous/overloaded
  • 18. So what about processes?
    Lots of flexibility
    Activities, components, receivers and providers can be in single process
    Can be split quite arbitrarily over different processes
    Defined in manifest
    All process run as uid of application
    All components run in a single main thread of application
    Need to ensure longer term tasks run in new thread
  • 19. Lifecycles - Activity
    Three states for activity
    Active or running
    Visible in foreground on screen
    Still visible, but not main focus
    When notification window open
    Not visible, retaining state
    More likely to be terminated
  • 20. Activity Lifecycle – state changes
    void onCreate(Bundle savedInstanceState)
    void onStart()
    void onRestart()
    void onResume()
    void onPause()
    void onStop()
    void onDestroy()
  • 21. Processes and lifecycles
    Android tends to use available resources
    Keeps things alive when in doubt
    Processes have one of 5 states:
    Foreground, visible, service, background, empty
    Process’s state may be linked to another process
    Service tied to foreground process
    When resources run low, lowest priority processes removed
  • 22. Android APIs
    Mix of APIs from different sources
    Apache http libs, standard java se libs, xml, jsonlibs
    Android-specific APIs
    Phone APIs
    Telephony, contacts, location, bluetooth/wifi
    Interface APIs
    Gesture, speech
    Widgets, webkit, opengl
  • 23. Android in the marketplace
    Android activity intense right now
    Over 50 devices in production or development
    Phones, tablets, e-readers, etc
    Sales of 60k units per day
    Adds up to 22m per annum
    iPhone sold 25m in 09
    App store rocketing
    Apps doubled in Q110
  • 24. Building an Android App
  • 25. Building an Android App
    What the (intended) app looked like
    How this was realized
    Mobile client
    How this was implemented
  • 26. Building an Android App
  • 27. Planned app…
    Integrate information from Facebook and Foursquare
    Facebook intended to provide rich network of relationships
    Foursquare to provide location aspects
    Application targetted at group of people on weekend away
    Hen/Stag party obvious example
  • 28. Intended workflow
    On the web…
    User goes to (stand alone) website
    Selects friends going on weekend away
    Facebook info
    Maps Facebook friends to Foursquare friends
    Somehow (?)
    Party going on tour stored in DB
    Both FB and FS uids stored
    …and over to mobile…
  • 29. Intended workflow
    Users download mobile app
    Used for duration of visit
    App can be used to
    Check in
    Check in on FS
    View group history
    Upload photos
    Make comments for group
    Provide for richer group experience
  • 30. Building an Android app
  • 31. Issues with development of backend
    Used Django framework
    Rapid development
    Used facebook and foursquare libraries for development
    Python/django libraries exist for both
    Multiple python facebook libraries exist
    Chose FB connect as main approach to talk to FB
    Django supports Oauthauthentiation based on this
  • 32. Issues with development of backend
    FB Connect libraries were a little limiting
    Very premised on notion that friends (of interest) are only those subscribed to site
    Common way to use FB Connect
    I wanted to extract all friends of given user
    Had to use some of the more conventional FB capabilities
    More focused on apps in FB
    Raised question of whether app should be housed in FB in first place
  • 33. Issues with development of backend
    Significant issue with mapping of FB users to FS users
    Although my friends on FS do have FB links
    (I don’t)
    Can iterate through friends lists to find matches
    Email remainder to sign up for FS
    Did not get this complete
  • 34. Issues with development of backend
    Foursquare API is still basic
    Underestimated maturity of this as platform
    Thought I could get friends history
    To show how people moved during the weekend
    FS API only allows access to last place friend was observed
    My backend needed to keep check ins also
    To show fuller picture of weekend
    Python FS API v simple to use
  • 35. Issues with development of backend
    Got basic capabilities working
    Authentication via FB
    Select list of FB friends going on weekend
    Get FS id of those who have simple mapping of FB to FS id
    In their FS profile
    Did not get important parts working
    Mobile API
    Photo support
    Poor design decisions when constructing DB
  • 36. Building an Android App
    Mobile client
  • 37. Android development
    Short overview of tools
    Very important
    Describe a little about how a simple Android app works
    Issues I had with FB, FS integration
  • 38. Android – getting up and running
    Android SDK
    Base tools common to all versions of platform
    Emulator framework
    cmd line tools to deploy apps on device
    IDE – Eclipse preferred
    ADT plug in
    Provides Android libraries, hooks into emulator, deployment, etc
    Android Platform versions
    Install in SDK
  • 39. Basic tools
    Main tool
    adb – flexible tool to enable host to talk to device
    Used to install package on device
    Put file on device
    Shell into device
    Show device logs – these include application error traces
    Other tools
    ddms – tool for connecting to on device process to debug
    apkbuilder – tool to generate android package (apk)
    Apk files used in market
    Can also be used to sign
    Tools for db management, libraries, etc
  • 40. Eclipse plug-in
    ADT is Eclipse plug-in for Android development
    Can be installed directly from online resource
    Features include:
    Knowledge of Android libraries
    Suggestions for completion of names/methods
    Reasonable support for layout of views
    Drag and drop elements onto canvas
    Good support for manipulation of manifest
    Debugging support
  • 41. External jars
    Possible to add external jars to application
    Often v useful for talking to network services
    Eg foursquare in this case
    Issue with jar for shipping app
    Jar must be included in package
    Unless it is known (how?) jar is available on device
    Addition of external jars straightforward in Eclipse
  • 42. A basic activity
    Class MyActivity extends Activity implements xxxListenersxxx {
    private EditTextusernameText = null ;
    private EditTextpasswordText = null ;
    Private Button button = null ;
    public void onCreate(Bundle savedInstanceState) {
    button = (Button)findViewById(;
    public void onClick(View v) {
  • 43. Basic activity: reacting to event
    public void onClick(View v) {
    // do something when the button is clicked
    // put the values in username and password into some
    // strings
    edittext1 = (EditText)findViewById(;
    edittext2 = (EditText)findViewById(;
    String username = edittext1.getText().toString();
    String password = edittext2.getText().toString();
  • 44. Moving on to next activity
    Approach is straightforward
    Create an intent and tell Android
    Some code:
    Intent myIntent = new Intent();
    myIntent.setClassName("", "");
    myIntent.putExtra("", "Hello, Joe!"); // key/value pair, where key needs current package prefix.
    Platform does manifest lookup to determine what to do
  • 45. When new activity instigated…
    Can receive information from previous activity
    Transfer mechanism somewhat invisible
    Activity class has getIntent() method
    Used to determine how activity was called
    Some code:
    public void onCreate(Bundle icicle) {
    Integer category = this.getIntent().getIntExtra("category", -1);
  • 46. More generally…moving data around
    Simple data can be transferred between activities using Bundles can be extended
    Incorporating global application state
    Public/static fields/methods
    A bit clunky
    Persistent storage:
    Application preferences, files, sqlite DB
  • 47. Issues with maps and keys
    MapView API requires keys for use
    Keys linked to developer and to application
    Unique key for each application
    For development phase…
    Android generates certificate for signing application automatically
    Not tied to certificate authority
    Submit hash of this certificate to obtain working key
    For release…
    Generate public/private key and use these to create certificate
  • 48. Progress
    Did not really get through facebook and foursquare functions on device
    Foursquare api looks simple, easy to use on android
    Library exists for this
    Facebook connect for android project is work in progress
    Did not look at this
  • 49. The 49thparallell
    Some upcoming activities
    UCD/EPITA Android Hackathon
    14-16 April
    Startup Weekend – NDRC
    7-9 May
    Opportunities day
    Invited Talk: ‘Mobile @ Google’
    Dave Burke, Engineering Manager, Google
    14 May
  • 50. Q&A