SlideShare une entreprise Scribd logo
1  sur  3
Télécharger pour lire hors ligne
Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 1
Hadnout#4
Problem Statement: Design and implement Calculator (Arithmetic
Operations) App using AsyncTask concept.
Theory:
Use of AsyncTask:
Use of AsyncTask is to run tasks, which consists computationally
intensive operations, asynchronously from the UI threads.
Need of AsyncTask:
Implementing multithreading if multiple threads are involved in
updating the UI is more tedious. This can be done with simple mechanism
provided in Android is called AsyncTask.
AsyncTask (Asynchronous Task)
 It enables proper and easy use of the UI thread.
 It allow to perform background operations and publish results on
the UI thread without having to manipulate threads and/or
handlers.
 It is designed to be a helper class around Thread and Handler and
does not constitute a generic threading framework.
 It should ideally be used for short operations (a few seconds at the
most.)
 It is defined by a computation that runs on a background thread
and whose result is published on the UI thread.
 It is defined by 3 generic types, called Params, Progress and Result,
and 4 steps, called onPreExecute, doInBackground,
onProgressUpdate and onPostExecute.
Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 2
AsyncTask deals with two key aspects:
(1) Execute the long-running task in the background (in a separate
thread)
Callback method: doInBackground(Params params..)
(2) Update the main thread as the task progresses or completes.
Callback method: onProgressUpdate(Progress… progress)
To meet above key aspects, AsyncTask class provides two key callback
methods:
(1) doInBackground(Params params…)
Gets executed on a separate thread in the background, different from
main thread.
is an ideal place for long-running tasks
(2) onProgressUpdate(Progress… progress)
Gets executed on the main thread
is suited to update the progress of the background task on UI.
(3) publishProgress(params)
Gets executed inside doInBackground(Params params…) method.
Helps to establish asynochronous communication between the
doInBackground () and onProgressUpdate()
An AsyncTask is implemented as a nested class of an Activity whose
UI it needs to Update.
[Reference: Book -“Mobile Apps Development” by Anubhav Pradhan, Anil V Deshpande]
Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 3
Design:
Steps:
1) Design an app to perform Arithmetic Operations such as Addition,
Subtraction and Multiplication for integer numbers.
2) Design layout with two TextView, two EditText, three TextView to
display results and “Submit” button.
3) User enters two numbers and click on “Submit” button.
4) On click of “Submit” button, two numbers passed to Asynchronous
Task thread to perform Addition, Subtraction and Multiplication of
two numbers.
5) Results performed in AsyncTask will be updated on main layout.
Questions:
1) What is asynTask in Android?
2) Illustrate the benefits of AsyncTask over Threads for implementing
long-running tasks.
3) Difference between AsyncTask & Handler in Android.
4) Explain concept of Handler & Looper in Android.
5) Explain event-handling paradigm with the help of example.

Contenu connexe

Tendances

Iterative development & rational unified process
Iterative development &  rational unified processIterative development &  rational unified process
Iterative development & rational unified process
poonam bora
 
Application for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo LocationsApplication for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo Locations
Mike Taylor
 
MOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARI
MOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARIMOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARI
MOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARI
SivaSankari36
 

Tendances (20)

Android application project presentation.
Android application project presentation.Android application project presentation.
Android application project presentation.
 
5 beginner android application development foundation
5 beginner android application development foundation5 beginner android application development foundation
5 beginner android application development foundation
 
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash ScreenMobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
 
Android app ppt
Android app pptAndroid app ppt
Android app ppt
 
job job
job jobjob job
job job
 
Android task manager project presentation
Android task manager project presentationAndroid task manager project presentation
Android task manager project presentation
 
Iterative development & rational unified process
Iterative development &  rational unified processIterative development &  rational unified process
Iterative development & rational unified process
 
Android article
Android articleAndroid article
Android article
 
Making Android Easier to Develop
Making Android Easier to DevelopMaking Android Easier to Develop
Making Android Easier to Develop
 
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, TimerMobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
 
Application for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo LocationsApplication for Data Sync Between Different geo Locations
Application for Data Sync Between Different geo Locations
 
Introduction to Android Programming by Dr.M.Pyingkodi-kongu engineering c...
Introduction to  Android   Programming by  Dr.M.Pyingkodi-kongu engineering c...Introduction to  Android   Programming by  Dr.M.Pyingkodi-kongu engineering c...
Introduction to Android Programming by Dr.M.Pyingkodi-kongu engineering c...
 
MOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARI
MOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARIMOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARI
MOBILE APPLICATIONS DEVELOPMENT -ANDROID BY SIVASANKARI
 
Difference between system software and application software
Difference between system software and application softwareDifference between system software and application software
Difference between system software and application software
 
Real-time Text Audio to Video PPT Converter Tablet App
Real-time Text Audio to Video PPT Converter Tablet AppReal-time Text Audio to Video PPT Converter Tablet App
Real-time Text Audio to Video PPT Converter Tablet App
 
Flutter single codebase to build your dream application for i os and android
Flutter single codebase to build your dream application for i os and android Flutter single codebase to build your dream application for i os and android
Flutter single codebase to build your dream application for i os and android
 
Case study on tablet application for real time video, audio and ppt conversion
Case study on tablet application for real time video, audio and ppt conversionCase study on tablet application for real time video, audio and ppt conversion
Case study on tablet application for real time video, audio and ppt conversion
 
Extensibility in application
Extensibility in applicationExtensibility in application
Extensibility in application
 
SeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android AppsSeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android Apps
 
Flutter app development company
Flutter app development companyFlutter app development company
Flutter app development company
 

Similaire à MobileAppDev Handout#4

2014_report
2014_report2014_report
2014_report
K SEZER
 
Parallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MPParallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MP
IJSRED
 
Android development training programme , Day 3
Android development training programme , Day 3Android development training programme , Day 3
Android development training programme , Day 3
DHIRAJ PRAVIN
 

Similaire à MobileAppDev Handout#4 (20)

Android Connecting to internet Part 2
Android  Connecting to internet Part 2Android  Connecting to internet Part 2
Android Connecting to internet Part 2
 
Android - Background operation
Android - Background operationAndroid - Background operation
Android - Background operation
 
Task programming
Task programmingTask programming
Task programming
 
Background Thread
Background ThreadBackground Thread
Background Thread
 
[Android] Multiple Background Threads
[Android] Multiple Background Threads[Android] Multiple Background Threads
[Android] Multiple Background Threads
 
djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...
djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...
djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...
 
Asynchronous Programming in Android
Asynchronous Programming in AndroidAsynchronous Programming in Android
Asynchronous Programming in Android
 
2014_report
2014_report2014_report
2014_report
 
Aneka
AnekaAneka
Aneka
 
Parallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MPParallelization of Graceful Labeling Using Open MP
Parallelization of Graceful Labeling Using Open MP
 
Analysis of 3-D Model in ANSYS 9.0 by Java Program and Macros Using Interlink...
Analysis of 3-D Model in ANSYS 9.0 by Java Program and Macros Using Interlink...Analysis of 3-D Model in ANSYS 9.0 by Java Program and Macros Using Interlink...
Analysis of 3-D Model in ANSYS 9.0 by Java Program and Macros Using Interlink...
 
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
 
Android development training programme , Day 3
Android development training programme , Day 3Android development training programme , Day 3
Android development training programme , Day 3
 
GCF
GCFGCF
GCF
 
Final sds of academic a webpage based android application
Final sds of academic a webpage based android applicationFinal sds of academic a webpage based android application
Final sds of academic a webpage based android application
 
Uma SunilKumar Resume
Uma SunilKumar ResumeUma SunilKumar Resume
Uma SunilKumar Resume
 
Device Drivers
Device DriversDevice Drivers
Device Drivers
 
Software Engineering
 Software Engineering  Software Engineering
Software Engineering
 
Android Application Development for Intel Platform
Android Application Development for Intel PlatformAndroid Application Development for Intel Platform
Android Application Development for Intel Platform
 
p850-ries
p850-riesp850-ries
p850-ries
 

Plus de trupti1976 (11)

MobileAppDev Handout#2
MobileAppDev Handout#2MobileAppDev Handout#2
MobileAppDev Handout#2
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
 
CP Handout#9
CP Handout#9CP Handout#9
CP Handout#9
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
 
CP Handout#7
CP Handout#7CP Handout#7
CP Handout#7
 
CP Handout#6
CP Handout#6CP Handout#6
CP Handout#6
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
CP Handout#3
CP Handout#3CP Handout#3
CP Handout#3
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
CP Handout#1
CP Handout#1CP Handout#1
CP Handout#1
 

Dernier

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Dernier (20)

Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 

MobileAppDev Handout#4

  • 1. Mobile Application Development T. S. Indi, IT Department, WIT Solapur Page 1 Hadnout#4 Problem Statement: Design and implement Calculator (Arithmetic Operations) App using AsyncTask concept. Theory: Use of AsyncTask: Use of AsyncTask is to run tasks, which consists computationally intensive operations, asynchronously from the UI threads. Need of AsyncTask: Implementing multithreading if multiple threads are involved in updating the UI is more tedious. This can be done with simple mechanism provided in Android is called AsyncTask. AsyncTask (Asynchronous Task)  It enables proper and easy use of the UI thread.  It allow to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.  It is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework.  It should ideally be used for short operations (a few seconds at the most.)  It is defined by a computation that runs on a background thread and whose result is published on the UI thread.  It is defined by 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute.
  • 2. Mobile Application Development T. S. Indi, IT Department, WIT Solapur Page 2 AsyncTask deals with two key aspects: (1) Execute the long-running task in the background (in a separate thread) Callback method: doInBackground(Params params..) (2) Update the main thread as the task progresses or completes. Callback method: onProgressUpdate(Progress… progress) To meet above key aspects, AsyncTask class provides two key callback methods: (1) doInBackground(Params params…) Gets executed on a separate thread in the background, different from main thread. is an ideal place for long-running tasks (2) onProgressUpdate(Progress… progress) Gets executed on the main thread is suited to update the progress of the background task on UI. (3) publishProgress(params) Gets executed inside doInBackground(Params params…) method. Helps to establish asynochronous communication between the doInBackground () and onProgressUpdate() An AsyncTask is implemented as a nested class of an Activity whose UI it needs to Update. [Reference: Book -“Mobile Apps Development” by Anubhav Pradhan, Anil V Deshpande]
  • 3. Mobile Application Development T. S. Indi, IT Department, WIT Solapur Page 3 Design: Steps: 1) Design an app to perform Arithmetic Operations such as Addition, Subtraction and Multiplication for integer numbers. 2) Design layout with two TextView, two EditText, three TextView to display results and “Submit” button. 3) User enters two numbers and click on “Submit” button. 4) On click of “Submit” button, two numbers passed to Asynchronous Task thread to perform Addition, Subtraction and Multiplication of two numbers. 5) Results performed in AsyncTask will be updated on main layout. Questions: 1) What is asynTask in Android? 2) Illustrate the benefits of AsyncTask over Threads for implementing long-running tasks. 3) Difference between AsyncTask & Handler in Android. 4) Explain concept of Handler & Looper in Android. 5) Explain event-handling paradigm with the help of example.