SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Multithreading in Android


         Ahsen Tahir
Talk Outline
 Android Overview
 Android Stack
 Android Development Tools
 Main Building Blocks (Activity Life Cycle)
 Threading in Android
 Multithreading via AsyncTask Class
 Multithreading via Handler -> MessagePassing &
  Post() method
Android Overview
Awesome Ingredients:
                                                   Semiconductor
 Open Source Platform                             Manufacturers
   Apache/MIT License
   Third party libraries rewritten

 Designed for Mobile Devices                         OHA
    Limited Memory, Battery & Speed
                                        Mobile                      Software
 Comprehensive platform               Operators                   Development




 Android is owned by Open Handset Alliance (OHA).
Android Stack Layers
    Linux Kernel        Dalvik Runtime
    Native Libraries    Application Framework
Android Stack Layers
Linux kernel layer
 Why linux kernel?
   Portability
   Security
   Features

 Linux kernel 2.6.39
 kernel enhancements
    Drivers, Pluggable modules, Power management, IPC
Android Stack Layers
Native Libraries
 Function Libraries
      Webkit, Media framework, SQLite
 Bionic Libs
      Optimized for embedded use: libc
 Native Servers
      Surface flinger(manager),Audio flinger
 Hardware Abstraction Libraries (HAL)
Android Stack Layers
Android RunTime
 Core Libraries                         Java Source    Java Source
      Mostly Java SE (No AWT & Swing)      Code           Code
      More features                          Java
                                            Compiler
                                                             Java
                                                           Compiler

 Dalvik VM                                              Java Byte
                                          Java Byte
      Low memory, slow cpu, no swap        Code           Code
       space                                                 Dex
                                                           Compiler



                                            Execution   Dalvik Byte
                                                           Code
                                                           Execution




                                          Java VM        Dalvik VM
Android Stack Layers
Application Framework
 Java Libraries Built for Android
 Services (Managers)
Android Development
Development requirements
 Android SDK
http://developer.android.com/sdk/index.html

 Eclipse IDE for Java Developers
http://www.eclipse.org/downloads/packages/release/helios/sr2

 Android Development Plugin
http://developer.android.com/sdk/eclipse-adt.html
Android Development
IDE & Tools
 Android SDK
   Class Library
   Emulator and System Images
   Documentation and Sample Code
   Developer Tools
       dx – Dalvik Cross-Assembler
       aapt – Android Asset Packaging Tool
       adb – Android Debug Bridge
       ddms – Dalvik Debug Monitor Service

 Eclipse IDE + ADT plugin
   UI creation easier, reduces development time
Android Development
Programming Languages
 Java
 C/C++ (Restricted official support)
     http://developer.android.com/sdk/ndk/index.html
Android Activity Life Cycle
 Activity -> GUI/Window on screen
 Activity Life Cycle
Threading in Android
 A Thread is a concurrent unit of execution.
 A thread has its own call stack for methods being
  invoked, their arguments and local variables.
 Each virtual machine instance has at least one main
  Thread running when it is started; typically, there
  are several others for housekeeping.
 The application might decide to launch additional
  Threads for specific.
Threading in Android
 Threads in the same VM interact and synchronize
  by the use of shared objects and monitors
  associated with these objects.
 There are basically two main ways of having a
  Thread execute application code.
      One is providing a new class that extends Thread and
       overriding its run() method.
      The other is providing a new Thread instance with a
       Runnable object during its creation.
 In both cases, the start() method must be called
  to actually execute the new Thread.
Threading in Android
 Threads share the process' resources but are able
  to execute independently.
 Applications responsibilities can be separated
      main thread runs UI, and
      slow tasks are sent to background threads.
 Particularly useful in the case of a single process
  that spawns multiple threads on top of a
  multiprocessor system. In this case real
  parallelism is achieved.
 Consequently, a multithreaded program operates
  faster on computer systems that have multiple
  CPUs.
Multithreading Via AsycTask
Using the AsyncTask Class
 AsyncTask enables proper and easy use of the UI thread.
 This class allows to perform background operations and
  publish results on the UI thread without having to
  manipulate threads and/or handlers.
 An asynchronous task is defined by a computation that runs
  on a background thread and whose result is published on the
  UI thread.
 An asynchronous task is defined
Multithreading in Android
Using the AsyncTask Class
Multithreading Via Handler
Handler allows you to send and process
 Message and Runnable objects associated
 with a thread's MessageQueue
 Each Handler instance is associated with a
 single thread and that thread's message
 queue
   (1) to schedule messages and runnables to be
    executed as some point in the future; and
   (2) to enqueue an action to be performed on a
    different thread than your own.
 Post(Runnable) & sendMessage(Message)
Thanks

Más contenido relacionado

La actualidad más candente

The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Languageintelliyole
 
Android : Architecture & Components
Android : Architecture & ComponentsAndroid : Architecture & Components
Android : Architecture & ComponentsAkash Bisariya
 
Android Layout
Android LayoutAndroid Layout
Android Layoutmcanotes
 
Android activity
Android activityAndroid activity
Android activityKrazy Koder
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android Aakash Ugale
 
Android chapter02-setup2-emulator
Android chapter02-setup2-emulatorAndroid chapter02-setup2-emulator
Android chapter02-setup2-emulatorguru472
 
Angular components
Angular componentsAngular components
Angular componentsSultan Ahmed
 
Android graphics
Android graphicsAndroid graphics
Android graphicsKrazy Koder
 
Android structure
Android structureAndroid structure
Android structureKumar
 
Android - Application Framework
Android - Application FrameworkAndroid - Application Framework
Android - Application FrameworkYong Heui Cho
 
Manipulating Android tasks and back stack
Manipulating Android tasks and back stackManipulating Android tasks and back stack
Manipulating Android tasks and back stackRan Nachmany
 
Presentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestatePresentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestateOsahon Gino Ediagbonya
 

La actualidad más candente (20)

The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Android : Architecture & Components
Android : Architecture & ComponentsAndroid : Architecture & Components
Android : Architecture & Components
 
Android Layout
Android LayoutAndroid Layout
Android Layout
 
Android activity
Android activityAndroid activity
Android activity
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
C#.NET
C#.NETC#.NET
C#.NET
 
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
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Android chapter02-setup2-emulator
Android chapter02-setup2-emulatorAndroid chapter02-setup2-emulator
Android chapter02-setup2-emulator
 
Angular components
Angular componentsAngular components
Angular components
 
Express js
Express jsExpress js
Express js
 
Android graphics
Android graphicsAndroid graphics
Android graphics
 
Introduction To C#
Introduction To C#Introduction To C#
Introduction To C#
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android structure
Android structureAndroid structure
Android structure
 
Android - Application Framework
Android - Application FrameworkAndroid - Application Framework
Android - Application Framework
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Manipulating Android tasks and back stack
Manipulating Android tasks and back stackManipulating Android tasks and back stack
Manipulating Android tasks and back stack
 
Presentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestatePresentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestate
 

Similar a Multithreading in Android

Similar a Multithreading in Android (20)

Lecture slides introduction_introduction
Lecture slides introduction_introductionLecture slides introduction_introduction
Lecture slides introduction_introduction
 
Introduction to Android platform
Introduction to Android platformIntroduction to Android platform
Introduction to Android platform
 
Java
JavaJava
Java
 
JAVA AND ANDROID OS_PRESENTATION
JAVA AND ANDROID OS_PRESENTATIONJAVA AND ANDROID OS_PRESENTATION
JAVA AND ANDROID OS_PRESENTATION
 
01 02 - introduction - adroid stack
01  02 - introduction - adroid stack01  02 - introduction - adroid stack
01 02 - introduction - adroid stack
 
Android Handheld Systems
Android Handheld SystemsAndroid Handheld Systems
Android Handheld Systems
 
DevNation
DevNation DevNation
DevNation
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for android
 
Android OS
Android OSAndroid OS
Android OS
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Introduction to the Android NDK
Introduction to the Android NDKIntroduction to the Android NDK
Introduction to the Android NDK
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 
Java notes
Java notesJava notes
Java notes
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Mobile Java
Mobile JavaMobile Java
Mobile Java
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android development process- thorsignia
Android development process- thorsigniaAndroid development process- thorsignia
Android development process- thorsignia
 
FRAUD DETECTION IN ONLINE AUCTIONING
FRAUD DETECTION IN ONLINE AUCTIONINGFRAUD DETECTION IN ONLINE AUCTIONING
FRAUD DETECTION IN ONLINE AUCTIONING
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 

Más de coolmirza143

Introduction Cell Processor
Introduction Cell ProcessorIntroduction Cell Processor
Introduction Cell Processorcoolmirza143
 
Cell processor lab
Cell processor labCell processor lab
Cell processor labcoolmirza143
 
Introduction Cell Processor
Introduction Cell ProcessorIntroduction Cell Processor
Introduction Cell Processorcoolmirza143
 
Map reduceoriginalpaper mandatoryreading
Map reduceoriginalpaper mandatoryreadingMap reduceoriginalpaper mandatoryreading
Map reduceoriginalpaper mandatoryreadingcoolmirza143
 
Distributed Computing & MapReduce
Distributed Computing & MapReduceDistributed Computing & MapReduce
Distributed Computing & MapReducecoolmirza143
 
Introduction to Real-Time Operating Systems
Introduction to Real-Time Operating SystemsIntroduction to Real-Time Operating Systems
Introduction to Real-Time Operating Systemscoolmirza143
 

Más de coolmirza143 (8)

Introduction Cell Processor
Introduction Cell ProcessorIntroduction Cell Processor
Introduction Cell Processor
 
Cell processor lab
Cell processor labCell processor lab
Cell processor lab
 
Introduction Cell Processor
Introduction Cell ProcessorIntroduction Cell Processor
Introduction Cell Processor
 
Map reduceoriginalpaper mandatoryreading
Map reduceoriginalpaper mandatoryreadingMap reduceoriginalpaper mandatoryreading
Map reduceoriginalpaper mandatoryreading
 
Distributed Computing & MapReduce
Distributed Computing & MapReduceDistributed Computing & MapReduce
Distributed Computing & MapReduce
 
Cuda lab manual
Cuda lab manualCuda lab manual
Cuda lab manual
 
Introduction to Real-Time Operating Systems
Introduction to Real-Time Operating SystemsIntroduction to Real-Time Operating Systems
Introduction to Real-Time Operating Systems
 
Cuda 2011
Cuda 2011Cuda 2011
Cuda 2011
 

Último

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Multithreading in Android

  • 2. Talk Outline  Android Overview  Android Stack  Android Development Tools  Main Building Blocks (Activity Life Cycle)  Threading in Android  Multithreading via AsyncTask Class  Multithreading via Handler -> MessagePassing & Post() method
  • 3. Android Overview Awesome Ingredients: Semiconductor  Open Source Platform Manufacturers  Apache/MIT License  Third party libraries rewritten  Designed for Mobile Devices OHA  Limited Memory, Battery & Speed Mobile Software  Comprehensive platform Operators Development Android is owned by Open Handset Alliance (OHA).
  • 4. Android Stack Layers  Linux Kernel  Dalvik Runtime  Native Libraries  Application Framework
  • 5. Android Stack Layers Linux kernel layer  Why linux kernel?  Portability  Security  Features  Linux kernel 2.6.39  kernel enhancements  Drivers, Pluggable modules, Power management, IPC
  • 6. Android Stack Layers Native Libraries  Function Libraries  Webkit, Media framework, SQLite  Bionic Libs  Optimized for embedded use: libc  Native Servers  Surface flinger(manager),Audio flinger  Hardware Abstraction Libraries (HAL)
  • 7. Android Stack Layers Android RunTime  Core Libraries Java Source Java Source  Mostly Java SE (No AWT & Swing) Code Code  More features Java Compiler Java Compiler  Dalvik VM Java Byte Java Byte  Low memory, slow cpu, no swap Code Code space Dex Compiler Execution Dalvik Byte Code Execution Java VM Dalvik VM
  • 8. Android Stack Layers Application Framework  Java Libraries Built for Android  Services (Managers)
  • 9. Android Development Development requirements  Android SDK http://developer.android.com/sdk/index.html  Eclipse IDE for Java Developers http://www.eclipse.org/downloads/packages/release/helios/sr2  Android Development Plugin http://developer.android.com/sdk/eclipse-adt.html
  • 10. Android Development IDE & Tools  Android SDK  Class Library  Emulator and System Images  Documentation and Sample Code  Developer Tools dx – Dalvik Cross-Assembler aapt – Android Asset Packaging Tool adb – Android Debug Bridge ddms – Dalvik Debug Monitor Service  Eclipse IDE + ADT plugin  UI creation easier, reduces development time
  • 11. Android Development Programming Languages  Java  C/C++ (Restricted official support)  http://developer.android.com/sdk/ndk/index.html
  • 12. Android Activity Life Cycle  Activity -> GUI/Window on screen  Activity Life Cycle
  • 13. Threading in Android  A Thread is a concurrent unit of execution.  A thread has its own call stack for methods being invoked, their arguments and local variables.  Each virtual machine instance has at least one main Thread running when it is started; typically, there are several others for housekeeping.  The application might decide to launch additional Threads for specific.
  • 14. Threading in Android  Threads in the same VM interact and synchronize by the use of shared objects and monitors associated with these objects.  There are basically two main ways of having a Thread execute application code.  One is providing a new class that extends Thread and overriding its run() method.  The other is providing a new Thread instance with a Runnable object during its creation.  In both cases, the start() method must be called to actually execute the new Thread.
  • 15. Threading in Android  Threads share the process' resources but are able to execute independently.  Applications responsibilities can be separated  main thread runs UI, and  slow tasks are sent to background threads.  Particularly useful in the case of a single process that spawns multiple threads on top of a multiprocessor system. In this case real parallelism is achieved.  Consequently, a multithreaded program operates faster on computer systems that have multiple CPUs.
  • 16. Multithreading Via AsycTask Using the AsyncTask Class  AsyncTask enables proper and easy use of the UI thread.  This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.  An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread.  An asynchronous task is defined
  • 17. Multithreading in Android Using the AsyncTask Class
  • 18. Multithreading Via Handler Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue  Each Handler instance is associated with a single thread and that thread's message queue  (1) to schedule messages and runnables to be executed as some point in the future; and  (2) to enqueue an action to be performed on a different thread than your own.  Post(Runnable) & sendMessage(Message)