Hire everyone in this theater we're going to go ahead and create another Android application.
So just click on this.
Start in your Android studio project.
So here for the application name just type in an app 51 dash Android lifecycle OK life cycle and then
click Next choose.
AP 16 Android 4.1 Jelly Bean for minimum STK phone and tablet.
OK.
Next on here choose Blanche activity next.
And then click can finish.
OK.
Now let's actually select this hello world takes you here and then present the key on your keyboard
and then it's actually go inside the stress folder.
Lay out activity on the line make that example and then select is faluting action button and then press
and delete key on your keyboard.
OK so now let's actually go back and say this main activity the double file here and then let's actually
delete these lines of code that are related to the Options menu and then deletes these lines of code
that are related to the floating action button.
Now I want to actually put in some more efforts inside inside of this class.
OK.
So as you can see this is the uncreate method.
OK.
This is actually one of the Android lifecycle efforts.
And now I want to add the other lifecycle methods inside this main activity class.
OK.
So first of all inside these are made I create if you want to actually create a toast in order to show
the user a message.
When my application runs.
OK.
So first of all in order to create a toast I need to refer to the name of the toaster class.
Ok toast.
OK.
That makes text.
So as you can see this cross-class has an effect.
A static method actually that we can call on this class or keep this in if it is a class my faith so
that we can call this method on this class.
OK.
And inside of the apprentice's of this Meffert we need to specify free arguments.
Ok so here for the first argument we need to specify the context.
OK.
So for the context context we can actually refer to that to this class.
OK so this.
OK comma.
And now I need to specify the text that you want to show to show the user.
OK so I just need to put in two double quotes and instead of double quotes I can just type in but the
UN create Meffert is called ok and comma and then I need to actually specify the duration of my message
or cater to change the direction of the message that is being shown to the user.
So here I can just type in TOSed
dot land line.
OK.
And now I need to actually call them if it's show on this method.
OK.
Undismayed text Meffert so that show.
OK so now it's going to actually show this message message to the user.
OK.
So let's actually add the other benefits here.
After the end in Kerley place of this uncreate Moffet.
Now I want to add the other lifecycle benefits to this class.
So the other lifecycle Mefford is the Meffert on start.
OK so I'm going to paste this method here and then I'm going to explain to you what's going on here.
So as you can see here this is the method on starts.
OK.
And as you can see the return type of the sign if it is void and the name of this if it is on start.
OK.
And as you can see here the access modifier of this method is protected and this means that this method
is only visible to the class that this it is actually created and there are some classes that inherit
from this class.
OK.
And as you can see here in say that this May 5th we are calling the super that Arne's and starts Moffit.
OK as we did for this uncreate benefit super that uncreate.
And now as you can see we actually created this toast here talks that make text.
This this is for the context of this application.
OK if you are referring to this class main activity that that is actually controlling the current activity
underline may not examine.
OK.
And here this is the text of our toast and starts Meffert is called.
OK.
And here the duration of the text.
OK.
To toast that line like that.
Sure.
OK.
And here we are actually showing that message to the user.
Now let's actually look at the other lifecycle Mefford.
So here I'm going to paste this method here and then I'm going to explain to you what's going on here.
OK.
So as you can see here the other it is always do OK.
So for the first time that this application is actually going to start.
So the first method that is going to be called is this method.
Uncreate.
OK.
And then it's going to show this message to the user.
And the second half that this is going to be called is this unstopped method.
OK.
And this message is going to be shown to the user and the first method that is going to be called is
this on resume Meffert.
OK as you can see and here it says TOSed that make text this and resume if it is called toast.
That red flag does show.
OK so now let's actually run our project and see what happens.
OK.
So as you can see the uncreate method is called the on start method is called and then the resume if
it is actually called.
OK.
So now let's actually call the other Democrats here it's actually create.
All right.
The other lifecycle fits inside of this class.
OK.
Inside of this main activity class.
So the other lifecycle Meffert that you want to put inside of this class is the unpause may.
So as you can see here this is the unposed Meffert.
OK.
And here as you can see I'm going to actually show this message to the user when this application is
actually on the unpassed state.
OK.
And now I want to actually override the other lifecycle effect here inside of this class.
So now I'm going actually pasting the other lifecycle effect inside of this class.
OK.
So as you can see here the other lifecycle method is these unrestored Mefford.
OK.
And here I'm going to actually show this message to the user and it is unrestored.
It is called.
OK.
And now let's actually put in the other lifecycle my it inside of this class.
So the other lifecycle Mefford is undestroyed Meffert.
OK.
So this method is going to be called Venda application.
Vendy activity is actually completely destroyed and we cannot and the activity is not stored in memory
anymore.
OK.
So some of it undestroyed is going to be called in that specific time.
And this message on the stream if it is called is going to be shown to the user.
OK so now let's actually run our project and see what happens.
OK.
So as you can see the uncreate Mfat is called.
OK.
And then the unstarted if it is called here and then the on resume if it is called.
Ok so now our application is actually under our resumes.
OK.
So now if I actually click on dispatch button let's see what happens.
So now let's actually click on dispatch button here and let's see what happens.
OK.
So as you can see here the opposite effect is called.
And then the undestroyed method is called.
So now the app our application is actually completely destroyed and it is not stored in memory anymore.
OK so now I can actually go back to our application I want to start my application again.
So here inside this main menu I can actually search for my application as you can see.
This is our app effective on Android lifecycle.
So the uncreate my is called the On-Star my faith is called.
And then the resume if it is caught.
So now our application is in the andr's state.
OK.
So here I want to actually to go to the home.
OK.
So the home screen of my emulator.
So I just need to click on this little circle here as you can see and as you can see the on plasma if
it is called.
And now our application is actually on the unpause state.
OK.
Now if you want to go back to my application let's see what happens here.
As you can see if I click on this little square here now I can see the other applications up in the
background.
OK.
So this application is actually in the background.
And now if I selected unrestored MURPHY It is called.
OK on start MFL this card and then the Andrew is you Mefford is going to be called.
So again our application is on.
Is your state.
OK.
So hopefully that makes sense.
And if you have any questions about Android lifecycle please post the discussion in the course and 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 year Tauriel.