Hi everyone in this theater they are really going to go ahead and create another Android application.
So just click on these.
Start in your Android studio project and then for the name of your application just type in here app
or 56 and then click on sit next and here choose AP 16 Android 4.1 Villepin and then click on next and
here choose empty activity next and he can finish.
So now as you can see here our project is actually created.
So let's actually double click on this and this folder here and then click on this lay out the directory
and then DoubleClick and this activity underline made that example here.
So now as you can see here now we want to actually design the user interface of our application so that
naturally select is hell over here and then press on delivery on your keyboard.
So now let's actually drive our linearly vertical into these relatively out here.
So just select is linearly as well as the cut and put it at the center of this relatively out here and
then let's actually drag out a large takes you into these linearly as vertical.
So just select is large the view here and put it at the center of this linearly as vertical and then
double click and it takes you here and then read the text of this takes you and for the ID to step in
here takes the high.
OK.
And then press Enter key on your keyboard.
So now this entry to the right button into this linearly as vertical and put it below these takes you.
And at the center of this nearly 20 COL W any spot in here and for the text just type in here.
Hi.
And for the ID just type in here between high and then press on until key on your keyboard.
So another design about user interface is actually finished.
So let's go back to what main activity that have a file here.
And now let's actually create some objects here.
So the first object that I want to actually declare here is going to be a text view object and the name
of my object is going to be tasty high and then I need to put a semicolon at the end of my statement.
And the second object is going to be of a button and the name of my object is going to be pretty high.
And then I need to put a semi-colon at the end of my statement.
So inside is uncreate Meffert.
Now able want to actually instantiate these two objects.
The first one is going to BTX the high assignment operator.
And then I need to cast this object to a text view object find view by id r r that ID that takes the
high and then I need to put a semicolon at the end of my statement and the second one is going to be
Pythian high assignment operator.
And then I need to cast this object to a button object find view by ID or ID that PTEN ID that pretty
high.
And then I need to put a semicolon at the end of my statement.
So now I want to actually make the spot and a listener to the police of the user.
So here I can just type in between and high that said Uncle listener and that I need to actually pass
the context.
So the context is going through the main activity that this and and here at the top I need to actually
implement so implements on the the view that unclick listener interface.
So if you start unclick listener.
OK so now I need to actually overwrite the and Meffert that is actually inside of this unclick isn't
an interface.
So here I can just point and click and then I need to press press Enter key on my keyboard.
So as you can see here the ankle my foot is actually over right here.
So this actually changed its name to view the arguments name to view.
And now I want to actually put some of the Android lifecycle MFX here and I want to actually show you
a really important point about the Android lifecycle.
OK.
So first of all let's actually create a string value or something valuable insight.
Our main activity class.
So here inside our main activity class here I just need to create a string variable.
So here I just need to refer to the name of this string class and the name of my variable is going to
be strange value.
OK.
And I need to put a semicolon here at the end of my statement and then here are inside our unclick Mefford
here.
I want to actually initialize this variable.
So here I can just type in a string value.
I just need to refer to the name of this rally or with the name of this object as you can see here setting
value assignment operator.
And here I can assign the value high to this body.
Okay to this object.
And now I can just type in here again just typing ATX the high data set text string value.
So now I want to actually assign the value of this string value valuable to this takes the high as you
can see here.
I want to assign the value of the string value variable to listen to this RTX the high stakes the high
that set text string value.
So now let's actually run our project and see what happens.
So here as you can see our application is running on the simulator here.
So if I click on the spot in here lets see what happens soon as I can see we have this value here high.
Ok for the state's view.
So this actually rotate the device and see what happens.
So just click on this rotate right here.
And now as you can see this value is gone.
OK.
So what's going on here.
So we have a very big problem here vended device is actually rotated on many devices actually in the
landscape mode.
OK.
The Andi's treatment for it is going to be called.
So for example now as you can see the device is actually in the portrait mode right.
And now I want to actually see my application in the landscape.
So if I click on this rotate right button here.
Now my application is actually in the landscape mode.
And when the device is going to actually change its orientation or for example from vertical to horizontal
or from horizontal to vertical the undestroyed Murphy is going to be called and undestroyed move it
is going to be called the application is going to be destroyed.
OK.
And that means that we are valuable as the value of our valuables are going to be actually empty and
we can see that we cannot see now the value of this takes here.
So if I click on this high button here again and and if I actually change the orientation of this device
now by clicking on this rotate left here.
Now as you can see the value of these tapes is gone.
So we need to save this value.
The value of that takes you up before the app the application is actually completely destroyed.
So let me actually paste in some other Android lifecycle if it's here and then it'll make sense to you.
So now after the creation of this article each method here as you can see inside this main activity
class I'm going to paste in some lines of code here and then I'm going to explain to you what's going
on here.
So as you can see here these are the lines of code that are actually pasted here.
OK.
So first of all let me explain to you what's going on here.
So I ask here first about I actually place that this method here.
So the access modifier of this method is public.
The return type of this method is void and the name of this method is let's create a toast.
OK.
So the job of this method is to actually create a toast and a short that goes to the user.
And this method actually accepts an argument of type strange and the name of this argument is message.
OK.
So inside this method as you can see inside the curly braces of this method I actually created a host
object.
So you referred to the name of this TOSed class that makes text.
First of all I actually passed the context main activity that this the second argument is going to be
the message that I want to show to the user.
So the message is going to be the argument that it's going to be passed to dismiss it.
Let's create a toast and a fresh argument is going to be and the failed argument is going to be the
length that is going to be shown to the user.
And finally what I'm actually calling this show Mefford on this object.
OK.
So that this toast is going to be shown to the user.
So as you can see here these are the Android lifecycle methods.
For example the uncreate Mefford is actually an android lifecycle Meffert.
So let's actually create a toast inside this uncreate Meffert in order to let the user know when the
uncreate if it is actually called.
Ok so here I can just refer to that to the name of this.
Let's create a two Smurfette.
Inside these uncreate method.
So let's create a toast and for the message I need to pass the message that I want to show to the user
so I can just type in the on create the create method is called Ok it's called.
So I just put this Meffert here.
Let's create a toast and then I actually put this message in order to show to the user that the uncreate
method is actually called Inside this uncreate method.
And the next Android lifecycle Meffert is actually the Smurfette on start Moffet.
So after this method here let's create a toss.
I actually pasted this method here on a start.
So as you can see here the axis modifier of this method is protected.
OK so you are actually inheriting this Smurfette from the superclass which is activity and as you can
see here we are all writing this class.
OK.
So the return type of the Smurfette is void and the name of this is unstuffed so honest thought Meffert
is going to be called after the uncreate method as you can see here.
So inside this unstarted effort as you can see first that what I am actually calling the super version
of the Smurfette Superlight on a slot and then in line 53 I am actually creating a tossed object in
order to show to the user that that Vendy unstarted if it is going to be called an honest start.
If it is going to be called after the uncreate Smurfit so after the unstarted if it is called the on
resume if it is going to be called ok as you can see here again we are inheriting this Merfeld from
the activity class and here as you can see in line fifty fifty eight you are actually calling the supervision
of the Smurfette superdad and raising of my fifth and in line 60 you are actually creating an object
or a host object in order to show to the user.
So let's create a toast and resume if it is called as you can see here.
And then as you can see here on here we have these on plasma.
So if the user clicks that clicks on the back button on the device or if the user for example switches
between the applications the unpeeled the unplausible if it is going to be called as you can see here.
So as you can see here again we are actually creating a host object in order to let the user know when
they are unpause if it is called.
And as you can see here we have this unstopped Meffert.
So after the unpause Mefford for example when the user clicks on the back button on the device at the
first level the positive it is going to be called.
And then the unstopped if it is going to be called.
Ok so here we are actually creating a tossed object in order to show to the user this message.
Honestly if it is called and then we have these on these three MF'er.
So this is going to be called of any application is actually destroyed from the memory and the information
inside the application is actually completely gone.
So as you can see I am actually creating a host object in order to let the user know that Vendy on the
stream if it is called and here we have two new methods.
OK you already saw these methods in the previous tutorials and actually talked about Android lifecycle
methods.
But these two methods are actually two new methods that of the Android lifecycle that I want to talk
about in this tutorial.