And here as you can see it says azing tasks should be ideally be used for short operations.
OK so a few seconds at the most.
OK.
So this is going to be actually this glass is used for short operations.
And as you can see here it's just a few seconds at the most.
So if you have for example tasks such as downloading an image from the internet or such tasks in your
application you can use this class azing task.
But if you need to keep Fretz running for long periods of time for example you have a very heavy task
and you can.
And you need to actually.
And it may take actually a lot of time.
OK.
It is highly recommended you use the various API is provided by the job that uty that can cart that
concurrent package such as executor.
Can are concurrent package such as the executer Fred Poole executed and future task.
So these are classes actually inside this Java that you that can current package.
I'll talk more about these classes later but for now we want to actually use this asynchronous async
task class and it's just that an asynchronous task is defined by computation that runs on a background
front and whose result is published under you like.
OK so let me try to read this line again.
An asynchronous task is defined by your computer nation that runs on a background Fred and whose result
is published on the UI for it an asynchronous task is defined by free generic types called pro-ams progress
resolved.
OK so let's try to go back to what Android studio here as you can see inside these angle brackets.
First of all I need to actually specify Dipodomys comma and the second level we need to specify the
progress.
OK comma and the first of all we need to specify the result.
OK the result that I want to actually get from the Internet for example the Possum's is going to be
the Padam meters.
Ok the input that we actually put inside is async task is in the background.
OK.
So our input is going to be for example.
And you are well.
So as you can see here I have this you are well and I want to actually download this image from the
internet and I actually chose this image here.
So as you can see here I actually selected this of you image here and as you can see this is going to
be the image.
And here is do all.
So the water is going to be off type strange putty.
So the perimeter as you can see here is going to be type strange.
So here I can just type in strange OK the data type is going to be of type string the data type of the
input that you want to actually put inside the async task is going to be of types to change.
And this is going to be that you are this you are is going to be inside to double quotes.
So this is going to be of type strange that you want to actually put as a pedometer for this async task.
So the second parimutuel as you can see here is progress.
So this progress paramita it is going to show us how much of the contents have been actually downloaded
from the Internet.
We can actually see what what percentage of the contents have been downloaded from the Internet and
then actually put that value somewhere in order to show to the user that what is going to be.
How much time is going to take for example to download this image this particular image from the Internet.
So that's the job of this pedometer.
And in the Android documentation as you can see here we have these descriptions here async tasks are
generic types.
And as you can see and it says patta progress the type of the Procrustes units published the type of
the Procrustes is published during the background computation.
OK.
So and as you can see here we have this result that type of the result of the background can computation.
So as you can see here because we want to actually download this image from the Internet.
So if you want to actually get an image from the Internet.
Right.
So that image is going to be offtake bitmap.
OK this is going to be the output the outputs that I want to get from these async task class is going
to be of type bitmap so that progress is going to be what.
I don't want to actually get disvalue.
OK.
Get these units published of the day for example and the image is downloaded from the internet.
I just want to put this Voyt value here.
I don't want to get any value here as a progress and the result is going to be offtake bitmap the bitmap
is actually the output.
So this thrain is the input that I want to put inside these async task and repeat map is the output
right.
So now I need to actually open and close this class using these curly braces but this opening curly
brace and these are closing calibrates.
So now we need to actually implement free methods here.
The first one is Vendi when the image is actually is going to download from the Internet.
OK.
Actually before downloading an image from the Internet is going to be dismembered on poorly executed
Meffert.
So this is going to be executed before downloading an image from the Internet.
OK.
The second effect is actually when the image is being downloaded from the Internet.
So that task is going to be in the background right.
So the name of this Meffert is going to be do in background as you can see here and here as you can
see the return type as of this Mufti's bitmap because here as you can see I specified that the output
type is going to be of type bitmap.
So I just select this Meffert here.
And as you can see here this is that Meffert to in background.
And the first method is going to be vente the image is actually downloaded from the Internet.
And the task of downloading is finished and then I want to put that image on the image for you and the
user interface as you can see here.
So that if it is going to be on post executes.
So these are the free important methods of this async task class.
OK.
So now inside this download image task class as you can see this is actually an inner class that is
inside of this main activity class.
So you can access these at user interface components variables or these methods that are inside the
outer class.
OK.
So inside this download image task class I want to actually first of all declare two objects the first
one is actually of type progress they like.
OK so you want to actually show it to the user a dialogue in order to let them know that the application
is actually downloading an image from the Internet.
And the name of this object is progress like semicolon.
OK.
And the second object that I want to actually declare here is of type context.
And the name of this context is context.
And then I need to put a semicolon at the end of my statement and then here I need to actually specify
a constructor for this download image task class.
So here I can just type in public and the name of the constructor must be the same as the name as the
name of this download image task class.
So here I can just type in download image task OK.
And then I need to put a pair of practices here and then I need to open and close this constructed by
using these curly braces.
And here I want to specify that these are constructed actually accepts an argument of type context.
OK so the name of this argument is going to be context.
OK.
And inside these are constructor you want to initialize these two objects that are actually declared
inside the standard image task class.
So the first one is progress Stalock assignment operator.
And here I can just typing new progress dialog.
And for the context as you can see here I can pass this context here and then put a semicolon at the
end of my statement.
And here are before initializing this progress Stalock I need to actually initialize this context object
because I am actually passing this context as a path emitter to this.
A constructed of this progress Daler class.
So here again I'll refer to the name of this context assignment operator.
So here as you can see I made this mistake when I actually referred to the name of this context here
it is that it is actually fairly in to this context as a Padam here because as you can see the name
of this instance variable here as you can see is actually the same as the name of this argument.
So when I actually inside this when I'm in say this a constructor and of a and I refer to the name of
this context it's going to actually refer to the.
To this construct to this context as a pattern.
OK.
So here I need to put this these here these that context.
So it is now referring to this context here inside this class download image task assignment operator.
So now you want to refer to the name of this context here as a padded me.
OK.
So now I am actually initializing this context that I actually get from this pattern meter is argument
here I am initializing the context here as you can see here this context context as you can see here
I am assigning this context that I get as a perimeter to this context here as you can see inside this
download image task.
So now that I can initialised my two objects now inside this on pre-text acute MFA Meffert when actually
put in some lines of code here.
So when the user actually wants to download the image from the internet why by clicking on the spot
in here I want to show them a message dialogue in order to let them know that an image is being downloaded
from the internet so they should wait.
OK.
So in order to do that as you can see I have this progress dialog uptick here so I can just refer to
the name of this object Proclus dialogue that sit message as you can see I mean it is an acute Meffert.
OK.
So this is going to be executed just before I actually click on the button download button and then
it can actually download the image from the Internet.
So this is the NPE execute method right.
Set message and inserted prentices.
I put the two double quotes on here I can just put the message.
For example downloading image.
Please visit
OK.