Hire anyone in this theater you are really going to go ahead and create another Android application.
So just click on this start in your Android studio project
and for the name of the application just type in hit app app 49 and then click on next and here choose.
AP is 16 Android 4.1 Jelly Bean for a minimum SDK.
And then click on next and here choose empty activity next and then click on finish.
So now as you can see our Android application is actually created.
So now let's actually go inside this this folder and then go is go inside this folder and then go inside
this activity Underland main that is and here.
And as you can see here this is the user interface of our application.
And as you can see I have this direct action bar theme here.
So if I click on it now I can actually select a theme for my user interface.
So I chose this material light and here I chose this one material that light the dark action one and
then click on OK.
So now I want to actually design the user interface of my application.
So here first of all because I want to actually download an image from it from the internet I need an
image view here so I'll just select this image inside this widgets folder and then put it here.
As you can see this is actually relatively out and I can actually put it anywhere I want and here as
you can see it's in these lines here.
And as you can see I am actually positioning this image view relatively to other components here on
the screen as you can see here.
Right.
So first of all let's actually drag linearly out of vertical vertical at the center of this relatively
out here.
So just put it at the center of this relatively out and then let's actually isolate this image view
here inside these widgets folder and put it here at the center of this linearly out vertical.
OK.
And here in the properties section as you can see here selectees image view and here as you can see
I have this layout with here.
OK.
So just selected and assigned the value 300 for the layout of this image view.
And as you can see selecting a layout height and here assigned the value of three hundred for the layout
height of this image view and then let's actually track our pattern here into this linearly out vertical.
So inside this widgets folder as you can see I have this button here.
Just select it and put it below this image view.
OK.
And double click on it.
So for the text just typing here.
Download an image from the Internet.
And for the ID just type in here between download image and then press Enter key on your keyboard.
So now the user interface as you can see here this is the user interface of my application.
And I actually finished the design of this user interface.
So now let's actually go back and say this main activity that I have a file here.
So first of all let's actually declare an object of type image view.
So Image view and the name of this image is going to be image view and then I put a semicolon at the
end of your statement.
So let's go back and say this activity on.
And in that example and if I double click on this image here as you can see the idea is in his view
right.
So let's go inside this man activity a double file here and now it's actually declared a button.
So button between download and then put a semi-colon at the end of your statement.
So inside this uncreate Smurfette that's actually initialize these objects that we declared inside this
main activity class.
So here I can just type an image view.
Assignment operator and then I can actually track this object to a image view object find view by ID
are that Id dot image view and then put a semicolon at the end of your statement.
And here let's actually initialize this PTEN download button.
So between download assignment operator so here that actually cast this object to a button object find
you by ID on that ID dot PTEN download and then put a semi-colon at the end of your statement.
So here you want to actually make the spot in this and as you can see here a listener to the clicks
of the user.
So in say the main activity that have a file here I just need to type in bit here and download the data
set on click listener and here inside the prentices I can just put this context in activity to this.
OK so this is going to be the context.
And now I need to actually implement the the view that Uncle listener interface.
So here at the top after this extends our computer activity I just need to type in implements and here
I need to refer to the name of my interface view that unclick listener.
OK.
So here we need to actually implement the abstract method that is inside this interface.
Uncle listener so that if it is on click OK.
So this is going to be that Meffert as you can see here.
So here are let's actually change the name of these arguments to view.
And if I click on this button here these are Meffert here as you can see it's going to be executed.
So now it's actually inside the main activity class.
Let's create an inner class.
OK.
So an inner class is actually like a usual class here as you can see here but and you know class is
inside this you know this outer class here.
For example this meant main activity class and an inner class actually actually I can access all the
features and behaviors of the outer class.
For example the instance variables are or the methods or other variables.
OK so here inside is our main activity class you want to actually create another class.
So make sure that you that you are actually inside this main activity class here.
So this is the curly braces at this end in curly brace is going to be the ending calibers of this main
activity class right.
So inside is our main activity class here.
I want to actually create an inner class.
So first of all I need to specify the axis modifier of the Smith of this class.
So here I can just type in private.
OK class and the name of this class is going to be download image task.
So the job of downloading the image from the Internet is going to be up for this class locate this class
is going to download an image from the Internet.
And then we can put that image on this image for you.
OK.
So I created a separate class for downloading an image from the Internet.
And the name of this class is download image task.
And this class extends OK from this scene.
Task here has class.
So what is this async task class.
So let's actually open the Android documentation.
So as you can see here if this is the android documentation you can actually put this all in your search
for Endeavor on your web browser here developer that Android dot com and you will be guided to this
page.
So inside the search here inside the search bar I can search for a scene our class here a sink task
class.
OK.
So this is going to be a syntax class.
So just select this class here as you can see Android AP Olly's.
So I have this azing test class.
And as you can see this class is actually public abstract.
OK so we cannot actually create an object directly from this class async task list.
And he had as he can see this class extends from the object class and here as you can see we have some
descriptions about this class here and it says a simple task enable is proper and easy use of the UI
it.
This class allows you to perform background operations and publish results on the UI for it without
having to manipulate Fritz and or hand-wrote handlers.
So what does this mean.
This means that because we want to actually download an image from the Internet and that task and downloading
an image from the end a task is actually a little bit heavy.
OK.
So if you want to actually put that task on the UI if read to you the user interface for it.
Going to actually take some time and our application may freeze or actually crash.
So because downloading an image from the internet is a truly is a heavy task.
We need to put that operation put that task in the background.
OK a background for it so that it's not going to actually block the user interface.
Ok so that the user can actually interact with the user interface while the emet is actually downloading
downloaded from the Internet.
OK.
And the user can actually interact with that application.
So that's the job of this class.
This class allows us to actually do something and put the operation of downloading the image from the
internet in the background for it not the UI for it.
OK.
And after the image is downloaded from the Internet we have a method and that if it is post execute
we have an.
And we can actually put that image which is downloaded from the Internet and we can put that image on
the UI thread on the user interface for it and we can show that image to the user.
So hopefully that makes sense.