SlideShare a Scribd company logo
mobile dev camp
android development workshop
                                                       amsterdam, november 2008


                                                   diego torres milano
                                                      diego@codtech.com
     copyright © 2008  cod technologies ltd  www.codtech.com
“I have always wished that my 
computer would be as easy to 
use as my telephone.
My wish has come true.
I no longer know how to use my 
telephone.”

                                                  ­­ Bjarne Stroustrup

      copyright © 2008  cod technologies ltd  www.codtech.com
agenda
●   introduction to android
●   android architecture
●   building blocks
●   your first android application
●   testing and performance
●   best practices
            copyright © 2008  cod technologies ltd  www.codtech.com
introduction to android
after this section you will...

                         ●   identify unique features of 
                             android platform
                         ●   compare android against 
                             other platforms
                         ●   understand android building 
                             blocks



             copyright © 2008  cod technologies ltd  www.codtech.com
what is android ?
●   android is the first complete, open 
    and free mobile platform
●   developed by Open Handset 
    Alliance
●   software stack than includes
    –   operating system
    –   middleware
    –   key applications
    –   rich set of APIs                         Portions of this page are reproduced from work created and 
                                                 shared by Google and used according to terms described in 
                                                               the Creative Commons 2.5 Attribution License.


                copyright © 2008  cod technologies ltd  www.codtech.com
is android linux ?
NO, android is not linux !
             android is based on a linux kernel  
                   but it's not GNU/Linux
                             ●   no native windowing 
                                 system
                             ●   no glibc support
                             ●   no GNU/Linux utilities



         copyright © 2008  cod technologies ltd  www.codtech.com
so is android java ?
NO, android is not java !
android is not an implementation 
of any of the Java variants
●   uses the java language
●   implements part of the 
    Java5 SE specification
●   runs on a dalvik virtual 
    machine instead of JVM


            copyright © 2008  cod technologies ltd  www.codtech.com
android linux kernel
android is based on a linux 2.6 kernel, providing
                                  rnel, p
●   security
●   memory management
●   process management
●   network stack
●   driver model
●   abstraction layer
kernel source: source.android.com

                copyright © 2008  cod technologies ltd  www.codtech.com
linux kernel enhancements
android introduces some linux kernel patches
●   alarm
●   ashmem
●   binder
●   power management
●   low memory killer (no swap space available)
●   logger


               copyright © 2008  cod technologies ltd  www.codtech.com
unique platform characteristics
android characteristics not found on other platforms

●   open source

●   “all applications are equal” model

●   dalvik virtual machine


             copyright © 2008  cod technologies ltd  www.codtech.com
other characteristics
interesting features as well, but they are more 
common across other mobile platforms
●   application framework enabling reuse of components
●   integrated browser based on WebKit OSS engine
●   3D graphics based on the OpenGL ES
●   SQLite for structured data storage
●   media support for common audio, video, and still images
●   camera, GPS, compass, and accelerometer


               copyright © 2008  cod technologies ltd  www.codtech.com
courtesy of Google
                     android architecture




                            copyright © 2008  cod technologies ltd  www.codtech.com
android building blocks
after this section you will...

                            ●   recognize the fundamental 
                                building blocks
                            ●   use these building blocks to 
                                create applications
                            ●   understand applications 
                                lifecycle


             copyright © 2008  cod technologies ltd  www.codtech.com
building blocks




       copyright © 2008  cod technologies ltd  www.codtech.com
Activities

                                      ●   Activities are stacked 
                                          like a deck of cards
                                      ●   only one is visible
                                      ●   only one is active
                                      ●   new activities are 
                                          placed on top



        copyright © 2008  cod technologies ltd  www.codtech.com
Activities lifecycle




rectangles are callbacks where
we can implement operations
performed on state changes


                    copyright © 2008  cod technologies ltd  www.codtech.com
Activities states
●   active
    –   at the top of the stack
●   paused
    –   lost focus but still visible
    –   can be killed by LMK
●   stopped
    –   not at the top of th stack
●   dropped
    –   killed to reclaim its memory

                 copyright © 2008  cod technologies ltd  www.codtech.com
Views

●   Views are basic building blocks

●   know how to draw themselves

●   respond to events

●   organized as trees to build up GUIs

●   described in XML in layout resources


             copyright © 2008  cod technologies ltd  www.codtech.com
pattern: load layout

android compiles the XML layout code that is 
later loaded in code usually by

                    public void onCreate(Bundle
                    savedInstanceState) {
                       ...

                    setContentView(R.layout.filename);
                       ...
                    }




          copyright © 2008  cod technologies ltd  www.codtech.com
Views and Viewgroups
●   Views and 
    Viewgroups trees 
    build up complex 
    GUIs
●   android framework is 
    responsible for
    –   measuring
    –   laying out
    –   drawing


                  copyright © 2008  cod technologies ltd  www.codtech.com
pattern: ids

using a unique id in a XML View definition 
permits locating it later in Java code

                     private View name;

                     public void onCreate(Bundle
                     savedInstanceState) {
                        ...
                           name = (View)
                               findViewById(R.id.name);
                        ...
                     }



           copyright © 2008  cod technologies ltd  www.codtech.com
Intents
●   Intents are used to move from Activity to Activity
●   describes what the application wants
●   provides late runtime binding


    primary attributes
    attribute description
    action   the general action to be performed, such as VIEW,
             EDIT, MAIN, etc.
    data     the data to operate on, such as a person record in
             the contacts database, as URI



                 copyright © 2008  cod technologies ltd  www.codtech.com
intents playground




    http://codtech.com/android/IntentPlayground.apk

          copyright © 2008  cod technologies ltd  www.codtech.com
Services
●   services run in the background
●   don't interact with the user
●   run on the main thread
    of the process
●   is kept running as long as
    –   is started
    –   has connections


                copyright © 2008  cod technologies ltd  www.codtech.com
Notifications

●   notify the user about 
    events
●   sent through 
    NotificationManager
●   types
    –   persistent icon
    –   turning leds
    –   sound or vibration


                copyright © 2008  cod technologies ltd  www.codtech.com
ConentProviders
●   ContentProviders are objects that can
    –   retrieve data
    –   store data
●   data is available to all applications
●   only way to share data across packages
●   usually the backend is SQLite
●   they are loosely linked to clients
●   data exposed as a unique URI
                copyright © 2008  cod technologies ltd  www.codtech.com
AndroidManifest.xml
●   control file that tells 
    the system what to do 
    and how the top­level 
    components are 
    related
●   it's the “glue” that 
    actually specifies 
    which Intents your 
    Activities receive
●   specifies permissions

              copyright © 2008  cod technologies ltd  www.codtech.com
your first android
after this section you will...
                        ●   create your own android map 
                            project
                        ●   design the UI
                        ●   externalize resources
                        ●   react to events
                        ●   run the application


             copyright © 2008  cod technologies ltd  www.codtech.com
android project




       copyright © 2008  cod technologies ltd  www.codtech.com
default application
                                      ●   auto­generated 
                                          application template
                                      ●   default resources
                                           –   icon
                                           –   layout
                                           –   strings
                                      ●   default 
                                          AndroidManifest.xml
                                      ●   default run 
                                          configuration
        copyright © 2008  cod technologies ltd  www.codtech.com
designing the UI
                                   this simple UI designs 
                                   contains
                                     ●   the window title
                                     ●   a spinner (drop down 
                                         box) containing the 
                                         desired location over 
                                         the map
                                     ●   a map displaying the 
                                         selected location

       copyright © 2008  cod technologies ltd  www.codtech.com
create the layout
                                      ●   remove old layout
                                      ●   add a RelativeLayout
                                      ●   add a View (MapView not 
                                          supported by ADT)

                                      ●   replace View by 
                                          com.google.android.m
                                          apview
                                      ●   change id to mapview
                                      ●   add a Spinner filling 
                                          parent width
        copyright © 2008  cod technologies ltd  www.codtech.com
run the application
                                      ●   com.google.android.
                                          maps it's an optional 
                                          library not included by 
                                          default
                                      ●   add <uses-library
                                          android:name=quot;com.go
                                          ogle.android.mapsquot; /
                                          > to manifest as 
                                          application node



        copyright © 2008  cod technologies ltd  www.codtech.com
Google Maps API key
●   checking DDMS logcat we find
    java.lang.IllegalArgumentException: You need to
    specify an API Key for each MapView.

●   to access Google Maps we need a key
●   application must be signed with the same key
●   key can be obtained from Google
●   MapView should include
    android:apiKey=quot;0GNIO0J9wdmcNm4gCV6S0nlaFE8bHa9W
    XXXXXXquot;

             copyright © 2008  cod technologies ltd  www.codtech.com
MapActivy
●   checking DDMS logcat again

    java.lang.IllegalArgumentException: MapViews can
    only be created inside instances of MapActivity.



●   change base class to MapActivity

●   fix imports

●   add unimplemented methods


              copyright © 2008  cod technologies ltd  www.codtech.com
where is the map ?
                                     ●   still no map displayed
                                     ●   check DDMS logcat
                                     ●   lots of IOExceptions !
                                     ●   some uses permissions 
                                         are missing
                                          –   ACCESS_COARSE_LOCATION

                                          –   INTERNET


       copyright © 2008  cod technologies ltd  www.codtech.com
finally our map

                                      still some problems ...
                                      ●   spinner is covered
                                          android:layout_alignPa
                                          rentTop=quot;truequot;


                                      ●   has no prompt
                                          prompt: @string/prompt

                                      ●   externalize resource


        copyright © 2008  cod technologies ltd  www.codtech.com
pattern: adapters

an Adapter object acts as a bridge between an 
AdapterView and the underlying data for that view

                        ArrayAdapter<CharSequence> adapter =
                           ArrayAdapter.createFromResource(
                             this, R.array.array,
                             android.R.layout.layout);

                        view.setAdapter(adapter);

The Adapter is also responsible for making a View for each item in the 
data set.

                copyright © 2008  cod technologies ltd  www.codtech.com
pattern: resources
resources are external files (that is, non­code files) 
that are used by your code and compiled into your 
application at build time.

                             <resources>
                                <string-array name=”array”>
                                   <item>item</item>
                                </string-array>
                             </resources>


                         res = getResources().getType(id);




             copyright © 2008  cod technologies ltd  www.codtech.com
arrays.xml
    <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>

    <resources>
    <!-- No support for multidimensional
     arrays or complex objects yet (1.0r1) -->

    <string-array name=quot;location_namesquot;>
       <item>Mediamatic Duintjer</item>
       <item>NH Hotel</item>
       <item>Airport</item>
    </string-array>

    <string-array name=quot;locationsquot;>
       <item>52.363125,4.892070,18</item>
       <item>37.244832,-115.811434,9</item>
       <item>-34.560047,-58.44924,16</item>
    </string-array>
    </resources>

         copyright © 2008  cod technologies ltd  www.codtech.com
complete the class
●   create the locations array
    locations =
      getResources().getStringArray(R.array.locations);

●   get the views (ids pattern)
     spinner = (Spinner) findViewById(R.id.Spinner01);
     mapView = (MapView) findViewById(R.id.mapview);

●   create the adapter
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.
        createFromResource(this,
    R.array.location_names,
          android.R.layout.simple_spinner_item);
    spinner.setAdapter(adapter)

               copyright © 2008  cod technologies ltd  www.codtech.com
almost there
                                     ●   map is displayed
                                     ●   spinner is displayed
                                     ●   drop down is 
                                         displayed
                                     ●   but there's no 
                                         selection button ...
                                      adapter.
                                         setDropDownViewResource(
                                            android.R.layout.
                                      simple_spinner_dropdown_item
                                      );



       copyright © 2008  cod technologies ltd  www.codtech.com
respond to events
                                     ●   when an item is 
                                         selected map should 
                                         be centered at that 
                                         location
                                 spinner.
                                    setOnItemSelectedListener(
                                     new
                                 OnItemSelectedListener() {
                                    });


                                     ●   invoke 
                                         goToSelectedLocation(ar
                                         g2);


       copyright © 2008  cod technologies ltd  www.codtech.com
goToSelectedLocation

 protected void goToSelectedLocation(int position) {
    String[] loc = locations[position].split(quot;,quot;);

     double lat = Double.parseDouble(loc[0]);
     double lon = Double.parseDouble(loc[1]);
     int zoom = Integer.parseInt(loc[2]);

     GeoPoint p = new GeoPoint((int)(lat * 1E6),
        (int)(lon * 1E6));

     Log.d(TAG, quot;Should go to quot; + p);

     mapController.animateTo(p);
     mapController.setZoom(zoom);
 }



            copyright © 2008  cod technologies ltd  www.codtech.com
more events
                                     ●   turn map clickable
                                         android:clickable=quot;true”

                                     ●   override onKeyDown
                                      switch (keyCode) {
                                      case KeyEvent.KEYCODE_I:
                                         mapController.zoomIn();
                                         break;
                                      case KeyEvent.KEYCODE_O:
                                         mapController.zoomOut();
                                         break;
                                      case KeyEvent.KEYCODE_S:
                                         mapView.setSatellite(
                                          !mapView.isSatellite());
                                         break;
                                      }


       copyright © 2008  cod technologies ltd  www.codtech.com
we did it !
                                       ●   Some things to try
                                            –   select a location

                                            –   pan

                                            –   zoom in

                                            –   zoom out

                                            –   toggle satellite


         copyright © 2008  cod technologies ltd  www.codtech.com
“Remember that there is no 
 code faster than no code”
        ­­ Taligent's Guide to Designing Programs




    copyright © 2008  cod technologies ltd  www.codtech.com
testing and performance
after this section you will...

                        ●   understand the best practices 
                            to develop for android
                        ●    identify the alternatives to test 
                            units, services and applications
                        ●   performance



             copyright © 2008  cod technologies ltd  www.codtech.com
best practices
●   consider performance, android is not a desktop
●   avoid creating objects
●   use native methods
●   prefer virtual over interface
●   prefer static over virtual
●   avoid internal getter/setters
●   declares constants final
●   avoid enums

              copyright © 2008  cod technologies ltd  www.codtech.com
testing
●   android sdk 1.0 introduces
    –   ActivityUnitTestCase to run isolated unit tests
    –   ServiceTestCase to test services
    –   ActivityInstrumentationTestCase to run functional 
        tests of activities
●   ApiDemos includes some test samples
●   monkey, generates pseudo­random of user 
    events

                copyright © 2008  cod technologies ltd  www.codtech.com
1000000
                                                                                                                                   1500000
                                                                                                                                             2000000
                                                                                                                                                       2500000
                                                                                                                                                                 3000000




                                                                                                                500000



                                                                                                     0
                                                                             Add a local variable


                                                                         Add a member variable


                                                                              Call String.length()


                                                                 Call empty static native method


                                                                       Call empty static method
                                                                                                                                                                           performance




                                                                      Call empty virtual method


                                                                    Call empty interface method


                                                               Call Iterator:next() on a HashMap


                                                                         Call put() on a HashMap


                                                                        Inflate 1 View from XML


                                                          Inflate 1 LinearLayout with 1 TextView

copyright © 2008  cod technologies ltd  www.codtech.com
                                                               Inflate 1 LinearLayout with 6 View


                                                          Inflate 1 LinearLayout with 6 TextView


                                                                       Launch an empty activity
                                                                                                         Time
summary
●   introduction to android
●   android building blocks
●




             copyright © 2008  cod technologies ltd  www.codtech.com
“If things seem under control, 
 you're not going fast enough.”
                                                         ­­ Mario Andretti




     copyright © 2008  cod technologies ltd  www.codtech.com
thank you
android development workshop
                                         diego torres milano
                                                    diego@codtech.com

     copyright © 2008  cod technologies ltd  www.codtech.com

More Related Content

What's hot

Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
Opersys inc.
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Android bootup process
Android bootup processAndroid bootup process
Android bootup process
Sanjay Kumar
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
Opersys inc.
 
Android
AndroidAndroid
Android
Jindal Gohil
 
Android Training
Android TrainingAndroid Training
Android Training
Tbldevelopment
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
National Cheng Kung University
 
Presentation on Wear OS (Android Wear)
Presentation on Wear OS (Android Wear)Presentation on Wear OS (Android Wear)
Presentation on Wear OS (Android Wear)
Adwait Hegde
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
National Cheng Kung University
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
Emertxe Information Technologies Pvt Ltd
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
Jussi Pohjolainen
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Android ppt
Android pptAndroid ppt
Android ppt
Tarun Bamba
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
National Cheng Kung University
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
National Cheng Kung University
 
Android Internals
Android InternalsAndroid Internals
Android Internals
Opersys inc.
 
Android testing
Android testingAndroid testing
Android testing
JinaTm
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
Opersys inc.
 
Android app development
Android app developmentAndroid app development
Android app development
Tanmoy Roy
 
Android studio
Android studioAndroid studio
Android studio
Paresh Mayani
 

What's hot (20)

Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Android bootup process
Android bootup processAndroid bootup process
Android bootup process
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Android
AndroidAndroid
Android
 
Android Training
Android TrainingAndroid Training
Android Training
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
 
Presentation on Wear OS (Android Wear)
Presentation on Wear OS (Android Wear)Presentation on Wear OS (Android Wear)
Presentation on Wear OS (Android Wear)
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android testing
Android testingAndroid testing
Android testing
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Android app development
Android app developmentAndroid app development
Android app development
 
Android studio
Android studioAndroid studio
Android studio
 

Similar to Android Development Workshop

Android Development Workshop V2
Android Development Workshop   V2Android Development Workshop   V2
Android Development Workshop V2
Diego Torres Milano
 
webthing-iotjs-tizenrt-cdl2018-20181117rzr
webthing-iotjs-tizenrt-cdl2018-20181117rzrwebthing-iotjs-tizenrt-cdl2018-20181117rzr
webthing-iotjs-tizenrt-cdl2018-20181117rzr
Phil www.rzr.online.fr
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
sullis
 
Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
Diego Torres Milano
 
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
Vando Batista
 
Introduction to Android - Mobile Portland
Introduction to Android - Mobile PortlandIntroduction to Android - Mobile Portland
Introduction to Android - Mobile Portland
sullis
 
Delivering Mobile Apps to the Field with Oracle JET
Delivering Mobile Apps to the Field with Oracle JETDelivering Mobile Apps to the Field with Oracle JET
Delivering Mobile Apps to the Field with Oracle JET
Simon Haslam
 
X Means Y
X Means YX Means Y
X Means Y
CommonsWare
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
natdefreitas
 
webthing-iotjs-20181027rzr
webthing-iotjs-20181027rzrwebthing-iotjs-20181027rzr
webthing-iotjs-20181027rzr
Phil www.rzr.online.fr
 
Android ppt
Android pptAndroid ppt
Dart on Arm - Flutter Bangalore June 2021
Dart on Arm - Flutter Bangalore June 2021Dart on Arm - Flutter Bangalore June 2021
Dart on Arm - Flutter Bangalore June 2021
Chris Swan
 
The rise of microservices
The rise of microservicesThe rise of microservices
The rise of microservices
Cloud Technology Experts
 
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Cisco DevNet
 
Øredev 2014
Øredev 2014Øredev 2014
Øredev 2014
olataube
 
Web 20- 2: Architecture Patterns And Models For The New Internet
Web 20- 2: Architecture Patterns And Models For The New InternetWeb 20- 2: Architecture Patterns And Models For The New Internet
Web 20- 2: Architecture Patterns And Models For The New Internet
tvawler
 
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
InfluxData
 
Session1 j2me introduction
Session1  j2me introductionSession1  j2me introduction
Session1 j2me introduction
muthusvm
 
Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...
Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...
Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...
Cisco DevNet
 
Getting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platformGetting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platform
Jean-Michel Bouffard
 

Similar to Android Development Workshop (20)

Android Development Workshop V2
Android Development Workshop   V2Android Development Workshop   V2
Android Development Workshop V2
 
webthing-iotjs-tizenrt-cdl2018-20181117rzr
webthing-iotjs-tizenrt-cdl2018-20181117rzrwebthing-iotjs-tizenrt-cdl2018-20181117rzr
webthing-iotjs-tizenrt-cdl2018-20181117rzr
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
 
Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
 
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
 
Introduction to Android - Mobile Portland
Introduction to Android - Mobile PortlandIntroduction to Android - Mobile Portland
Introduction to Android - Mobile Portland
 
Delivering Mobile Apps to the Field with Oracle JET
Delivering Mobile Apps to the Field with Oracle JETDelivering Mobile Apps to the Field with Oracle JET
Delivering Mobile Apps to the Field with Oracle JET
 
X Means Y
X Means YX Means Y
X Means Y
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
webthing-iotjs-20181027rzr
webthing-iotjs-20181027rzrwebthing-iotjs-20181027rzr
webthing-iotjs-20181027rzr
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Dart on Arm - Flutter Bangalore June 2021
Dart on Arm - Flutter Bangalore June 2021Dart on Arm - Flutter Bangalore June 2021
Dart on Arm - Flutter Bangalore June 2021
 
The rise of microservices
The rise of microservicesThe rise of microservices
The rise of microservices
 
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
Webex Teams Widgets Technical Drill down - Cisco Live Orlando 2018 - DEVNET-3891
 
Øredev 2014
Øredev 2014Øredev 2014
Øredev 2014
 
Web 20- 2: Architecture Patterns And Models For The New Internet
Web 20- 2: Architecture Patterns And Models For The New InternetWeb 20- 2: Architecture Patterns And Models For The New Internet
Web 20- 2: Architecture Patterns And Models For The New Internet
 
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
 
Session1 j2me introduction
Session1  j2me introductionSession1  j2me introduction
Session1 j2me introduction
 
Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...
Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...
Integrated, Automated Video Room Systems - Webex Devices - Cisco Live Orlando...
 
Getting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platformGetting started with open mobile development on the Openmoko platform
Getting started with open mobile development on the Openmoko platform
 

Recently uploaded

Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 

Recently uploaded (20)

Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 

Android Development Workshop

  • 1. mobile dev camp android development workshop amsterdam, november 2008 diego torres milano diego@codtech.com copyright © 2008  cod technologies ltd  www.codtech.com
  • 3. agenda ● introduction to android ● android architecture ● building blocks ● your first android application ● testing and performance ● best practices copyright © 2008  cod technologies ltd  www.codtech.com
  • 4. introduction to android after this section you will... ● identify unique features of  android platform ● compare android against  other platforms ● understand android building  blocks copyright © 2008  cod technologies ltd  www.codtech.com
  • 5. what is android ? ● android is the first complete, open  and free mobile platform ● developed by Open Handset  Alliance ● software stack than includes – operating system – middleware – key applications – rich set of APIs Portions of this page are reproduced from work created and  shared by Google and used according to terms described in  the Creative Commons 2.5 Attribution License. copyright © 2008  cod technologies ltd  www.codtech.com
  • 6. is android linux ? NO, android is not linux ! android is based on a linux kernel   but it's not GNU/Linux ● no native windowing  system ● no glibc support ● no GNU/Linux utilities copyright © 2008  cod technologies ltd  www.codtech.com
  • 7. so is android java ? NO, android is not java ! android is not an implementation  of any of the Java variants ● uses the java language ● implements part of the  Java5 SE specification ● runs on a dalvik virtual  machine instead of JVM copyright © 2008  cod technologies ltd  www.codtech.com
  • 8. android linux kernel android is based on a linux 2.6 kernel, providing rnel, p ● security ● memory management ● process management ● network stack ● driver model ● abstraction layer kernel source: source.android.com copyright © 2008  cod technologies ltd  www.codtech.com
  • 9. linux kernel enhancements android introduces some linux kernel patches ● alarm ● ashmem ● binder ● power management ● low memory killer (no swap space available) ● logger copyright © 2008  cod technologies ltd  www.codtech.com
  • 10. unique platform characteristics android characteristics not found on other platforms ● open source ● “all applications are equal” model ● dalvik virtual machine copyright © 2008  cod technologies ltd  www.codtech.com
  • 11. other characteristics interesting features as well, but they are more  common across other mobile platforms ● application framework enabling reuse of components ● integrated browser based on WebKit OSS engine ● 3D graphics based on the OpenGL ES ● SQLite for structured data storage ● media support for common audio, video, and still images ● camera, GPS, compass, and accelerometer copyright © 2008  cod technologies ltd  www.codtech.com
  • 12. courtesy of Google android architecture copyright © 2008  cod technologies ltd  www.codtech.com
  • 13. android building blocks after this section you will... ● recognize the fundamental  building blocks ● use these building blocks to  create applications ● understand applications  lifecycle copyright © 2008  cod technologies ltd  www.codtech.com
  • 14. building blocks copyright © 2008  cod technologies ltd  www.codtech.com
  • 15. Activities ● Activities are stacked  like a deck of cards ● only one is visible ● only one is active ● new activities are  placed on top copyright © 2008  cod technologies ltd  www.codtech.com
  • 17. Activities states ● active – at the top of the stack ● paused – lost focus but still visible – can be killed by LMK ● stopped – not at the top of th stack ● dropped – killed to reclaim its memory copyright © 2008  cod technologies ltd  www.codtech.com
  • 18. Views ● Views are basic building blocks ● know how to draw themselves ● respond to events ● organized as trees to build up GUIs ● described in XML in layout resources copyright © 2008  cod technologies ltd  www.codtech.com
  • 19. pattern: load layout android compiles the XML layout code that is  later loaded in code usually by public void onCreate(Bundle savedInstanceState) { ... setContentView(R.layout.filename); ... } copyright © 2008  cod technologies ltd  www.codtech.com
  • 20. Views and Viewgroups ● Views and  Viewgroups trees  build up complex  GUIs ● android framework is  responsible for – measuring – laying out – drawing copyright © 2008  cod technologies ltd  www.codtech.com
  • 21. pattern: ids using a unique id in a XML View definition  permits locating it later in Java code private View name; public void onCreate(Bundle savedInstanceState) { ... name = (View) findViewById(R.id.name); ... } copyright © 2008  cod technologies ltd  www.codtech.com
  • 22. Intents ● Intents are used to move from Activity to Activity ● describes what the application wants ● provides late runtime binding primary attributes attribute description action the general action to be performed, such as VIEW, EDIT, MAIN, etc. data the data to operate on, such as a person record in the contacts database, as URI copyright © 2008  cod technologies ltd  www.codtech.com
  • 23. intents playground http://codtech.com/android/IntentPlayground.apk copyright © 2008  cod technologies ltd  www.codtech.com
  • 24. Services ● services run in the background ● don't interact with the user ● run on the main thread of the process ● is kept running as long as – is started – has connections copyright © 2008  cod technologies ltd  www.codtech.com
  • 25. Notifications ● notify the user about  events ● sent through  NotificationManager ● types – persistent icon – turning leds – sound or vibration copyright © 2008  cod technologies ltd  www.codtech.com
  • 26. ConentProviders ● ContentProviders are objects that can – retrieve data – store data ● data is available to all applications ● only way to share data across packages ● usually the backend is SQLite ● they are loosely linked to clients ● data exposed as a unique URI copyright © 2008  cod technologies ltd  www.codtech.com
  • 27. AndroidManifest.xml ● control file that tells  the system what to do  and how the top­level  components are  related ● it's the “glue” that  actually specifies  which Intents your  Activities receive ● specifies permissions copyright © 2008  cod technologies ltd  www.codtech.com
  • 28. your first android after this section you will... ● create your own android map  project ● design the UI ● externalize resources ● react to events ● run the application copyright © 2008  cod technologies ltd  www.codtech.com
  • 29. android project copyright © 2008  cod technologies ltd  www.codtech.com
  • 30. default application ● auto­generated  application template ● default resources – icon – layout – strings ● default  AndroidManifest.xml ● default run  configuration copyright © 2008  cod technologies ltd  www.codtech.com
  • 31. designing the UI this simple UI designs  contains ● the window title ● a spinner (drop down  box) containing the  desired location over  the map ● a map displaying the  selected location copyright © 2008  cod technologies ltd  www.codtech.com
  • 32. create the layout ● remove old layout ● add a RelativeLayout ● add a View (MapView not  supported by ADT) ● replace View by  com.google.android.m apview ● change id to mapview ● add a Spinner filling  parent width copyright © 2008  cod technologies ltd  www.codtech.com
  • 33. run the application ● com.google.android. maps it's an optional  library not included by  default ● add <uses-library android:name=quot;com.go ogle.android.mapsquot; / > to manifest as  application node copyright © 2008  cod technologies ltd  www.codtech.com
  • 34. Google Maps API key ● checking DDMS logcat we find java.lang.IllegalArgumentException: You need to specify an API Key for each MapView. ● to access Google Maps we need a key ● application must be signed with the same key ● key can be obtained from Google ● MapView should include android:apiKey=quot;0GNIO0J9wdmcNm4gCV6S0nlaFE8bHa9W XXXXXXquot; copyright © 2008  cod technologies ltd  www.codtech.com
  • 35. MapActivy ● checking DDMS logcat again java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity. ● change base class to MapActivity ● fix imports ● add unimplemented methods copyright © 2008  cod technologies ltd  www.codtech.com
  • 36. where is the map ? ● still no map displayed ● check DDMS logcat ● lots of IOExceptions ! ● some uses permissions  are missing – ACCESS_COARSE_LOCATION – INTERNET copyright © 2008  cod technologies ltd  www.codtech.com
  • 37. finally our map still some problems ... ● spinner is covered android:layout_alignPa rentTop=quot;truequot; ● has no prompt prompt: @string/prompt ● externalize resource copyright © 2008  cod technologies ltd  www.codtech.com
  • 38. pattern: adapters an Adapter object acts as a bridge between an  AdapterView and the underlying data for that view ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.array, android.R.layout.layout); view.setAdapter(adapter); The Adapter is also responsible for making a View for each item in the  data set. copyright © 2008  cod technologies ltd  www.codtech.com
  • 39. pattern: resources resources are external files (that is, non­code files)  that are used by your code and compiled into your  application at build time. <resources> <string-array name=”array”> <item>item</item> </string-array> </resources> res = getResources().getType(id); copyright © 2008  cod technologies ltd  www.codtech.com
  • 40. arrays.xml <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <resources> <!-- No support for multidimensional arrays or complex objects yet (1.0r1) --> <string-array name=quot;location_namesquot;> <item>Mediamatic Duintjer</item> <item>NH Hotel</item> <item>Airport</item> </string-array> <string-array name=quot;locationsquot;> <item>52.363125,4.892070,18</item> <item>37.244832,-115.811434,9</item> <item>-34.560047,-58.44924,16</item> </string-array> </resources> copyright © 2008  cod technologies ltd  www.codtech.com
  • 41. complete the class ● create the locations array locations = getResources().getStringArray(R.array.locations); ● get the views (ids pattern) spinner = (Spinner) findViewById(R.id.Spinner01); mapView = (MapView) findViewById(R.id.mapview); ● create the adapter ArrayAdapter<CharSequence> adapter = ArrayAdapter. createFromResource(this, R.array.location_names, android.R.layout.simple_spinner_item); spinner.setAdapter(adapter) copyright © 2008  cod technologies ltd  www.codtech.com
  • 42. almost there ● map is displayed ● spinner is displayed ● drop down is  displayed ● but there's no  selection button ... adapter. setDropDownViewResource( android.R.layout. simple_spinner_dropdown_item ); copyright © 2008  cod technologies ltd  www.codtech.com
  • 43. respond to events ● when an item is  selected map should  be centered at that  location spinner. setOnItemSelectedListener( new OnItemSelectedListener() { }); ● invoke  goToSelectedLocation(ar g2); copyright © 2008  cod technologies ltd  www.codtech.com
  • 44. goToSelectedLocation protected void goToSelectedLocation(int position) { String[] loc = locations[position].split(quot;,quot;); double lat = Double.parseDouble(loc[0]); double lon = Double.parseDouble(loc[1]); int zoom = Integer.parseInt(loc[2]); GeoPoint p = new GeoPoint((int)(lat * 1E6), (int)(lon * 1E6)); Log.d(TAG, quot;Should go to quot; + p); mapController.animateTo(p); mapController.setZoom(zoom); } copyright © 2008  cod technologies ltd  www.codtech.com
  • 45. more events ● turn map clickable android:clickable=quot;true” ● override onKeyDown switch (keyCode) { case KeyEvent.KEYCODE_I: mapController.zoomIn(); break; case KeyEvent.KEYCODE_O: mapController.zoomOut(); break; case KeyEvent.KEYCODE_S: mapView.setSatellite( !mapView.isSatellite()); break; } copyright © 2008  cod technologies ltd  www.codtech.com
  • 46. we did it ! ● Some things to try – select a location – pan – zoom in – zoom out – toggle satellite copyright © 2008  cod technologies ltd  www.codtech.com
  • 47. “Remember that there is no  code faster than no code” ­­ Taligent's Guide to Designing Programs copyright © 2008  cod technologies ltd  www.codtech.com
  • 48. testing and performance after this section you will... ● understand the best practices  to develop for android ●  identify the alternatives to test  units, services and applications ● performance copyright © 2008  cod technologies ltd  www.codtech.com
  • 49. best practices ● consider performance, android is not a desktop ● avoid creating objects ● use native methods ● prefer virtual over interface ● prefer static over virtual ● avoid internal getter/setters ● declares constants final ● avoid enums copyright © 2008  cod technologies ltd  www.codtech.com
  • 50. testing ● android sdk 1.0 introduces – ActivityUnitTestCase to run isolated unit tests – ServiceTestCase to test services – ActivityInstrumentationTestCase to run functional  tests of activities ● ApiDemos includes some test samples ● monkey, generates pseudo­random of user  events copyright © 2008  cod technologies ltd  www.codtech.com
  • 51. 1000000 1500000 2000000 2500000 3000000 500000 0 Add a local variable Add a member variable Call String.length() Call empty static native method Call empty static method performance Call empty virtual method Call empty interface method Call Iterator:next() on a HashMap Call put() on a HashMap Inflate 1 View from XML Inflate 1 LinearLayout with 1 TextView copyright © 2008  cod technologies ltd  www.codtech.com Inflate 1 LinearLayout with 6 View Inflate 1 LinearLayout with 6 TextView Launch an empty activity Time
  • 52. summary ● introduction to android ● android building blocks ● copyright © 2008  cod technologies ltd  www.codtech.com
  • 53. “If things seem under control,  you're not going fast enough.” ­­ Mario Andretti copyright © 2008  cod technologies ltd  www.codtech.com
  • 54. thank you android development workshop diego torres milano diego@codtech.com copyright © 2008  cod technologies ltd  www.codtech.com