And here are actually I need to show this program Stalock to the user so I can just type in progress
larg progress dialog that show.
So now it's going actually show this message to the user on this preexist cute method and here as you
can see I mean scientists doing background.
So this is the Meffert that is actually going to download the image from the internet in the background.
The key not the user interface for it.
So let's actually delete this line of code here returns.
And here I'm actually putting some lines of code here so I'm going to paste in some lines of code here
and then I'm going explain to you what's going on here.
So as you can see here these are the lines of code that actually pasted here.
And inside this method as you can see I created of the table of type.
Strange as you can see here in line 18.
And the name of this valuable is strange.
You are an assignment operator.
So here I'll refer to this part arms array.
So remember is permitted is actually of type.
Ali I told you about this type of Aure in the jobs section of the course.
OK.
Putnam's as you can see here.
And here I am actually putting this Index index zero.
OK.
So here as you can see I have this Aure and this is going to be the index 0.
And this means that when you want to actually download an image from the internet you need to actually
pass a pedometer an argument in order to actually for example lead the application know that I want
to download an image from the Internet's 5:22 you are able to that specific method.
OK.
And I'll show you that Meffert in a minute.
And here as you can see this is going to be the data type of that method.
As you can see and we have an array.
OK.
So the index zero of that array is going to be that you are.
OK.
Because I want to download an image only one image from the internet so you have only one of your RL
so that you are it is going to be placed inside the index zero of this alley of this prom's addy.
OK.
So that's why I actually would put this perhaps.
Here are you referred to the name of this Ali and I put this in zero here because I have I have only
one you are.
So I just put this you are a zero.
And then it's going to actually download the image from the Internet by using that specific you are
ill.
He had that I actually specify here.
So here you referred to the name of this part.
OK.
Perhaps Ari Suppe index zero as you can see here.
So this is going to be that you all OK.
And here I am assigning that specific humoral to this string you are in here that I actually created
here.
OK.
And in light ativan I actually created an object of type bitmap and then I assigned a value to this
bitmap object.
So here I have this try catch exception here.
And hid inside the trite statement here as you can see in the try block here I have this I have these
lines of quote.
First of all I created an object of type you r l and the name of this object is you are it.
And here I am actually instantiating this you Arel by using this strange model that I created in line
80 new you Ardell.
So here I want to instantiate this you are an object by using this string you are that I actually get
to use that one through example with an image from the Internet.
So remember that I told you about this you are here.
This is going to be inserted double quotes.
So this is going to be.
And actually when you are ill.
So insight and anthrax to do.
Now you can see that you want to actually use this strange model in order to download an image from
the Internet.
So that's why I created this you are an object.
And then in order to download an image from the union we need to actually create an object of type input
stream and the name of this object is in input stream.
Assignment operator you are ill that open stream so it can actually open the website that we want to
actually download an image from the Internet.
And here I referred to the name of this bitmap object.
OK.
So bitmap factory D-CT stream.
So it's clear here.
This is going to actually download that specific Meffert that specific image from that stream.
Here are two input stream that decode stream input stream or keep it back to the class that decode stream
input stream so it can actually return an object of type bitmap.
So it's going to actually assign that object to this bitmap object that is going to assign that image
to this bitmap object.
OK.
And here I have this catch statement.
So this catch block is going actually is going to be executed of any.
For example when downloading the image from the Internet from the Internet is going to actually fail.
So you need to catch this error here and we can actually put that to the log.
So for example catch that print is text.
It prints that traces can actually put the information to the lug.
And here we are returning that object returned bitmap from the background.
So when the image is actually downloaded from the Internet it's going to return.
It's going to return the bitmap object and inside our unposed execute Meffert.
As you can see we have this bitmap object as a pad image OK.
I have this beaten up other object as a pad emitter as you can see this object that is returned from
the screen background.
It is going to be as a pad image here of this unposted execute.
So this Meffert is going to be run on the UI for it so I can actually show that image to the user.
So in order to do that again just take the image view that.
So as you can see here I am referring to this image inside these outer class main activity class.
So here I can just take an image that sets image bitmap as you can see here.
I can actually assign an object of type bitmap here bitmap.
OK so now because I am actually inside this and post execute Meffert and this means that this method
actually runs on the UI thread I can actually I need to actually stop showing this progress day luck
that I actually started showing here in line in an execute Nefert.
I need to actually stop showing that progress.
I like to use that because the image is actually downloaded from the internet so here I can't just create
an if statement if progress dialog that is showing.
And inside this statement I can't just they can progress they lag that dismiss so now let's say our
project and see what happens.
So before running our project as you can see I have this error here and I actually mistakenly assigned
this rank ID for the speaker and download the actual ID of this PTEN download is between download image.
OK.
So let's actually change this up PTEN download here to between download image and now here at the top
in our main activity class let's change this the name of the city and download to PTEN download image.
OK.
But as you can see here again architecture will change the speed and download to PTEN download image.
And now the errors are gone.
OK so now let's actually run our project and see what happens.
So now as you can see our application is running on the simulator.
So if we click on the spot in here it's not going to actually download the image from the Internet.
So there is a problem here and the problem is that we didn't we didn't actually put the logic inside
this uncle Mefford in order to download that image from the Internet.
So first of all in order to download an image from the Internet we need to actually create an object
of type download image task class.
OK so this class is actually responsible for downloading the image from the Internet.
So in order to download this image from the internet I need to create an object of type download image
task.
So the name of this object is download image task assignment operator new download image task and as
you can see here for the constructor of this class I specified that this class accepts an argument of
type context.
So the context is going to be main activity that this semicolon and then here I can just type in download
image task I referred to the name of this download image task object that executes at inside Apprentice's
of this download of this execute Meffert as you can see here.
I have this pattern is a part of type A string of a.
So here I need to put you out of here.
So here are inside this Apprentice's.
I can just put into double quotes and in our Web browser as you can see I have this you are all here.
OK.
So I just need to copy this you are RL And inside these double codes I can put that you are all here
and at the end of my statement I need to put up put a semicolon here.
So this is going to be my you are l and I called this execute my foot on this download image task object.
So let's run our project again and this time let's see what happens.
So as you can see here our application is running on this emulator here.
And now let's actually click on the spot in here download an image from the Internet.
And as you can see here I cannot download this image from the Internet.
So now what's the problem.
The problem is inside the Android manifest as you can see here inside this manifest file.
We need to put put actually a permission in order to actually get the permission of the user in order
to access the Internet because they want to use the Internet in order to download an image from the
Internet.
So here I need to put that permission is this manifest tagging as you can see here.
I need to put that permission.
So here I need to open this permission here.
This tag uses permission and inside the double quotes I can just type in Internet and select this one
and then close this permission here.
So now I can actually run our project again.
So here as you can see our application is running on this emulator.
So let's actually click on the spot in here again.
And now as you can see we can see this progress dialog downloading image.
Please wait.
And here we can see this image and we successfully download this image from the Internet.
OK.
So I think that's enough for this tutorial and I think you can you can actually figure out how to download
an image from the internet now.
So if you have any questions please post the discussion in the course and then I'll do my best to answer
all of your questions.
Thank you very much for watching and I'll see you in the next tutorial.