SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Mobile application development
Mobile application developmentMobile application development
Mobile application developmentEric Cattoir
 
Layouts in android
Layouts in androidLayouts in android
Layouts in androidDurai S
 
Understanding android security model
Understanding android security modelUnderstanding android security model
Understanding android security modelPragati Rai
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installationPoojaBele1
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android StudioSuyash Srijan
 
Requirements gathering and validation for mobile applications
Requirements gathering and validation for mobile applicationsRequirements gathering and validation for mobile applications
Requirements gathering and validation for mobile applicationsK Senthil Kumar
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecturedeepakshare
 
Android PPT Presentation 2018
Android PPT Presentation 2018Android PPT Presentation 2018
Android PPT Presentation 2018Rao Purna
 
Software Engineering Methodologies
Software Engineering MethodologiesSoftware Engineering Methodologies
Software Engineering MethodologiesDamian T. Gordon
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaAjay Sharma
 
Android async task
Android async taskAndroid async task
Android async taskMadhu Venkat
 

Was ist angesagt? (20)

Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Process scheduling linux
Process scheduling linuxProcess scheduling linux
Process scheduling linux
 
Android UI
Android UIAndroid UI
Android UI
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Understanding android security model
Understanding android security modelUnderstanding android security model
Understanding android security model
 
Android ipm 20110409
Android ipm 20110409Android ipm 20110409
Android ipm 20110409
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installation
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
Requirements gathering and validation for mobile applications
Requirements gathering and validation for mobile applicationsRequirements gathering and validation for mobile applications
Requirements gathering and validation for mobile applications
 
Android ppt
Android ppt Android ppt
Android ppt
 
Android Memory Management
Android Memory ManagementAndroid Memory Management
Android Memory Management
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installation
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Android PPT Presentation 2018
Android PPT Presentation 2018Android PPT Presentation 2018
Android PPT Presentation 2018
 
Software Engineering Methodologies
Software Engineering MethodologiesSoftware Engineering Methodologies
Software Engineering Methodologies
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Android async task
Android async taskAndroid async task
Android async task
 
Java basics
Java basicsJava basics
Java basics
 

Ähnlich wie Multithreading in Android

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
[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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Kürzlich hochgeladen (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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...
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
[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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

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)