SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Android Application Development
              Daniel Switkin
   Senior Software Engineer, Google Inc.
Goal

• Get you an idea of how to start developing
  Android applications
• Introduce major Android application concepts
• Walk you through a sample application in the
  development environment
Agenda


•   System architecture

•   Hello World!

•   Application components

•   Practical matters

•   Toolchain
What is Android?

• A free, open source mobile platform
• A Linux-based, multiprocess, multithreaded OS
• Android is not a device or a product
• It’s not even limited to phones - you could build
  a DVR, a handheld GPS, an MP3 player, etc.
Applications

    Home             Contacts           Phone         Browser                         ...

                              Application Framework

Activity Manager     Window            Content         View                       Notification
                     Manager           Providers      System                       Manager

Package Manager      Telephony         Resource       Location                    GTalk Service
                      Manager          Manager        Manager


                   Libraries                            Android Runtime
Surface Manager        Media            SQLite                   Core Libraries
                    Framework

 OpenGL | ES         FreeType          WebKit                    Dalvik Virtual
                                                                   Machine

      SGL               SSL              libc


                                   Linux Kernel
    Display        Camera Driver      Bluetooth     Flash Memory                  Binder (IPC)
    Driver                              Driver          Driver                       Driver

  USB Driver       Keypad Driver      WiFi Driver     Audio                         Power
                                                      Drivers                     Management
Hello World!
The History of GUIs


• Hardcoded to the screen
• Hardcoded to the window
• Hardcoded within a view hierarchy
• Dynamic layout within a view hierarchy
Generating GUIs
• Two ways to create GUIs: in XML or in code
 • Declarative route via XML has advantages
• A lot of your GUI-related work will take place in:
 •res/layout
 •res/values
•@id/name_for_component gives you
  handle for referencing XML declarations in code
Views

• Views are building blocks
• Examples:
 • Can be as basic as: TextView, EditText, or
    ListView
 • Fancier views: ImageView, MapView, WebView
Layouts
• Controls how Views are laid out
 • FrameLayout : each child a layer
 • LinearLayout : single row or column
 • RelativeLayout : relative to other Views
 • TableLayout : rows and columns
 • AbsoluteLayout : <x,y> coordinates
Layouts are resizable




480x320

                        240x320


                        320x240
Layouts are customizable




res/layout/share.xml   res/layout-land/share.xml
Layout Parameters
• Specify many aspects of what’s being rendered
• Examples:
 • android:layout_height
 •  android:layout_width

• Tip: start with documentation for a specific View
  or Layout and then look at what’s inherited from
  parent class
Application Components
Basic components
                   UI component typically
    Activities
                   corresponding to one screen.
BroadcastReceivers Respond to broadcast Intents.
                   Faceless tasks that run in the
     Services
                   background.
ContentProviders   Enable applications to share data.
Activities

• Typically correspond to one screen in a UI
• But, they can:
 • be faceless
 • be in a floating window
 • return a value
Intents
• Think of Intents as a verb and object; a
  description of what you want done
 • Examples: VIEW, CALL, PLAY, etc.
• System matches Intent with Activity that can best
  provide that service
• Activities and BroadcastReceivers describe what
  Intents they can service in their IntentFilters (via
  AndroidManifest.xml)
Intents

    Home



   Contacts
                                     Photo
              “Pick photo”           Picasa
                                     Gallery

    GMail



    Chat
                 New components
                 Components can makes
                 System picks best can
                 Client componentbe usea
                 existing any specific
                 replacedfunctionality
                 component for that action
                 request for a time action
   Blogger
BroadcastReceivers

• Components designed to respond to broadcast
  Intents
• Think of them as a way to respond to external
  notifications or alarms
• Applications can invent and broadcast their own
  Intents as well
Services

• Faceless components that run in the background
 • Example: music player, network downlaod, etc.
• Bind your code to a running service via a
  remote-able interface defined in an IDL
• Can run in your own process or separate
  process
ContentProviders
• Enables sharing of data across applications
 • Examples: address book, photo gallery, etc.
• Provides uniform APIs for:
 • querying (returns a Cursor)
 • delete, update, and insert rows
• Content is represented by URI and MIME type
Practical matters
Storage and Persistence

• A couple of different options:
 • Preferences
 • Flat file
 • SQLite
 • ContentProvider
Packaging


• Think of .apk files as Android packages
• Everything needed for an application is bundled
  up therein
• Basically a glorified ZIP file
Resources
• res/layout: declarative layout files
• res/drawable: intended for drawing
• res/anim: bitmaps, animations for transitions
• res/values: externalized values for things like
  strings, colors, styles, etc.

• res/xml: general XML files used at runtime
• res/raw: binary files (e.g. sound)
Assets
• Similar to Resources
• Differences:
 • Read-only
 • InputStream access to assets
• Any kind of file
 • Be mindful of file sizes
Application Lifecycle

• Application lifecycle is managed by the system
• Application start/stop is transparent to the user
• End-user only sees that they are moving between
  screens
• Read documentation for android.app.Activity
Toolchain
Emulator

           • QEMU-based ARM emulator
             runs same system image as
             a device

           • Use same toolchain to work
             with devices or emulator
Eclipse Plugin
Project template
Debugging

 Call stack



                                Examine variables




 Breakpoints, single stepping
Eclipse demo
Q &A

Contenu connexe

Tendances

Tendances (8)

ENVI/IDL for HDF
ENVI/IDL for HDFENVI/IDL for HDF
ENVI/IDL for HDF
 
Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010
 
Open Android
Open AndroidOpen Android
Open Android
 
Colors
ColorsColors
Colors
 
Exchange with anypoint platform
Exchange with anypoint platformExchange with anypoint platform
Exchange with anypoint platform
 
Android For Managers Slides
Android For Managers SlidesAndroid For Managers Slides
Android For Managers Slides
 
Web based tool for domain specific modeling
Web based tool for domain specific modeling Web based tool for domain specific modeling
Web based tool for domain specific modeling
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 

En vedette

Insani degerleri yasamak (1)
Insani degerleri yasamak (1)Insani degerleri yasamak (1)
Insani degerleri yasamak (1)taha4423
 
Presentation1
Presentation1Presentation1
Presentation1tharkness
 
Sivil toplum kuruluslari
Sivil toplum kuruluslariSivil toplum kuruluslari
Sivil toplum kuruluslaritaha4423
 
Przegląd rysunków – Robert Ratajczak
Przegląd rysunków – Robert RatajczakPrzegląd rysunków – Robert Ratajczak
Przegląd rysunków – Robert Ratajczakratajczak.robert
 
Insan hayatina ve_onuruna_saygi (1)
Insan hayatina ve_onuruna_saygi (1)Insan hayatina ve_onuruna_saygi (1)
Insan hayatina ve_onuruna_saygi (1)taha4423
 
Presentation1
Presentation1Presentation1
Presentation1tharkness
 

En vedette (9)

11
1111
11
 
Insani degerleri yasamak (1)
Insani degerleri yasamak (1)Insani degerleri yasamak (1)
Insani degerleri yasamak (1)
 
Presentation1
Presentation1Presentation1
Presentation1
 
Sivil toplum kuruluslari
Sivil toplum kuruluslariSivil toplum kuruluslari
Sivil toplum kuruluslari
 
3hafta
3hafta3hafta
3hafta
 
Przegląd rysunków – Robert Ratajczak
Przegląd rysunków – Robert RatajczakPrzegląd rysunków – Robert Ratajczak
Przegląd rysunków – Robert Ratajczak
 
Insan hayatina ve_onuruna_saygi (1)
Insan hayatina ve_onuruna_saygi (1)Insan hayatina ve_onuruna_saygi (1)
Insan hayatina ve_onuruna_saygi (1)
 
Presentation1
Presentation1Presentation1
Presentation1
 
12
1212
12
 

Similaire à Android application development

Introduction to Android
Introduction to AndroidIntroduction to Android
Introduction to AndroidNitinMehra2205
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidJawad Mohmand
 
Android Workshop_1
Android Workshop_1Android Workshop_1
Android Workshop_1Purvik Rana
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkImam Raza
 
Introduction to Android (before 2015)
Introduction to Android (before 2015)Introduction to Android (before 2015)
Introduction to Android (before 2015)Chien-Ming Chou
 
Android General information
Android General informationAndroid General information
Android General informationPrashant Gosai
 
Android OS and its Features
Android OS and its FeaturesAndroid OS and its Features
Android OS and its FeaturesHarshad Lokhande
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osArnav Gupta
 
Android Application Development GDSC DCE Darbhanga.pptx
Android Application Development GDSC DCE Darbhanga.pptxAndroid Application Development GDSC DCE Darbhanga.pptx
Android Application Development GDSC DCE Darbhanga.pptxDCETechnicalClub
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersBoom Shukla
 
Android- Introduction for Beginners
Android- Introduction for BeginnersAndroid- Introduction for Beginners
Android- Introduction for BeginnersTripti Tiwari
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentCan Elmas
 
Synapseindia android apps application development
Synapseindia android apps application developmentSynapseindia android apps application development
Synapseindia android apps application developmentSynapseindiappsdevelopment
 

Similaire à Android application development (20)

Lecture3
Lecture3Lecture3
Lecture3
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
My androidpresentation
My androidpresentationMy androidpresentation
My androidpresentation
 
Android quick talk
Android quick talkAndroid quick talk
Android quick talk
 
Introduction to Android
Introduction to AndroidIntroduction to Android
Introduction to Android
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android Workshop_1
Android Workshop_1Android Workshop_1
Android Workshop_1
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
 
Introduction to Android (before 2015)
Introduction to Android (before 2015)Introduction to Android (before 2015)
Introduction to Android (before 2015)
 
Android General information
Android General informationAndroid General information
Android General information
 
Android OS and its Features
Android OS and its FeaturesAndroid OS and its Features
Android OS and its Features
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
Androidify workshop
Androidify workshopAndroidify workshop
Androidify workshop
 
Android Application Development GDSC DCE Darbhanga.pptx
Android Application Development GDSC DCE Darbhanga.pptxAndroid Application Development GDSC DCE Darbhanga.pptx
Android Application Development GDSC DCE Darbhanga.pptx
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
Android Training
Android TrainingAndroid Training
Android Training
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
 
Android- Introduction for Beginners
Android- Introduction for BeginnersAndroid- Introduction for Beginners
Android- Introduction for Beginners
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Synapseindia android apps application development
Synapseindia android apps application developmentSynapseindia android apps application development
Synapseindia android apps application development
 

Dernier

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 

Dernier (20)

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

Android application development

  • 1. Android Application Development Daniel Switkin Senior Software Engineer, Google Inc.
  • 2. Goal • Get you an idea of how to start developing Android applications • Introduce major Android application concepts • Walk you through a sample application in the development environment
  • 3. Agenda • System architecture • Hello World! • Application components • Practical matters • Toolchain
  • 4. What is Android? • A free, open source mobile platform • A Linux-based, multiprocess, multithreaded OS • Android is not a device or a product • It’s not even limited to phones - you could build a DVR, a handheld GPS, an MP3 player, etc.
  • 5. Applications Home Contacts Phone Browser ... Application Framework Activity Manager Window Content View Notification Manager Providers System Manager Package Manager Telephony Resource Location GTalk Service Manager Manager Manager Libraries Android Runtime Surface Manager Media SQLite Core Libraries Framework OpenGL | ES FreeType WebKit Dalvik Virtual Machine SGL SSL libc Linux Kernel Display Camera Driver Bluetooth Flash Memory Binder (IPC) Driver Driver Driver Driver USB Driver Keypad Driver WiFi Driver Audio Power Drivers Management
  • 7. The History of GUIs • Hardcoded to the screen • Hardcoded to the window • Hardcoded within a view hierarchy • Dynamic layout within a view hierarchy
  • 8. Generating GUIs • Two ways to create GUIs: in XML or in code • Declarative route via XML has advantages • A lot of your GUI-related work will take place in: •res/layout •res/values •@id/name_for_component gives you handle for referencing XML declarations in code
  • 9. Views • Views are building blocks • Examples: • Can be as basic as: TextView, EditText, or ListView • Fancier views: ImageView, MapView, WebView
  • 10. Layouts • Controls how Views are laid out • FrameLayout : each child a layer • LinearLayout : single row or column • RelativeLayout : relative to other Views • TableLayout : rows and columns • AbsoluteLayout : <x,y> coordinates
  • 11. Layouts are resizable 480x320 240x320 320x240
  • 13. Layout Parameters • Specify many aspects of what’s being rendered • Examples: • android:layout_height • android:layout_width • Tip: start with documentation for a specific View or Layout and then look at what’s inherited from parent class
  • 15. Basic components UI component typically Activities corresponding to one screen. BroadcastReceivers Respond to broadcast Intents. Faceless tasks that run in the Services background. ContentProviders Enable applications to share data.
  • 16. Activities • Typically correspond to one screen in a UI • But, they can: • be faceless • be in a floating window • return a value
  • 17. Intents • Think of Intents as a verb and object; a description of what you want done • Examples: VIEW, CALL, PLAY, etc. • System matches Intent with Activity that can best provide that service • Activities and BroadcastReceivers describe what Intents they can service in their IntentFilters (via AndroidManifest.xml)
  • 18. Intents Home Contacts Photo “Pick photo” Picasa Gallery GMail Chat New components Components can makes System picks best can Client componentbe usea existing any specific replacedfunctionality component for that action request for a time action Blogger
  • 19. BroadcastReceivers • Components designed to respond to broadcast Intents • Think of them as a way to respond to external notifications or alarms • Applications can invent and broadcast their own Intents as well
  • 20. Services • Faceless components that run in the background • Example: music player, network downlaod, etc. • Bind your code to a running service via a remote-able interface defined in an IDL • Can run in your own process or separate process
  • 21. ContentProviders • Enables sharing of data across applications • Examples: address book, photo gallery, etc. • Provides uniform APIs for: • querying (returns a Cursor) • delete, update, and insert rows • Content is represented by URI and MIME type
  • 23. Storage and Persistence • A couple of different options: • Preferences • Flat file • SQLite • ContentProvider
  • 24. Packaging • Think of .apk files as Android packages • Everything needed for an application is bundled up therein • Basically a glorified ZIP file
  • 25. Resources • res/layout: declarative layout files • res/drawable: intended for drawing • res/anim: bitmaps, animations for transitions • res/values: externalized values for things like strings, colors, styles, etc. • res/xml: general XML files used at runtime • res/raw: binary files (e.g. sound)
  • 26. Assets • Similar to Resources • Differences: • Read-only • InputStream access to assets • Any kind of file • Be mindful of file sizes
  • 27. Application Lifecycle • Application lifecycle is managed by the system • Application start/stop is transparent to the user • End-user only sees that they are moving between screens • Read documentation for android.app.Activity
  • 29. Emulator • QEMU-based ARM emulator runs same system image as a device • Use same toolchain to work with devices or emulator
  • 31. Debugging Call stack Examine variables Breakpoints, single stepping
  • 33. Q &A