The first one is the unsaved instance state and as I can see here you are inheriting this never from
the superclass activity and this if it should accept an argument of type bundle and the name of this
argument is saved instance state and in line 86 we are actually in the supervision of this if it's that
super unsafe instance State save instance that we are passing this argument here and in line 88 we are
actually creating a host object and we want to show dismiss to the user on save instance.
It is called.
So I want to let the user know Vendy Smurfette is actually being called.
And here we have this unrestored instance that as you can see here and again this is actually an effort
that we are inheriting from the superclass.
And as you can see in line 94 you're actually calling it the super version of the Smurfette.
And in 96 I actually created a tossed object in order to let the user know when this method is going
to be called on unrestored instance statement for this card.
So let's run our project and see Wendy's or Android lifecycle.
My efforts are going to be called.
So I hate to hit the run button here and then click on OK.
The uncreate for this called the unstarted if it is called the on resume if it is called Right.
So first the create method is called and then the on if it is called.
And finally the andr's your method is called.
So now our application is actually in the resume state as you can see here.
So now let's actually click on the spot and here and here as you can see we have this high stakes here.
OK.
So let's actually rotate the device rotate right and change the device orientation as you can see here
and now you can see the positive for this card.
And then the save instance is called and unstopped met for this card and undestroyed of this card.
And finally again the uncreate for this card.
And unstarted if it is called and Andreas for instance it is called.
And finally the resume if it is called.
So let me actually go inside these Meffert these are let's create a them if it here as you can see and
change these short to lend long.
And let's run our project again.
Let me get you to change the orientation again to vertical.
First of all the uncreate if it is caught right and then the On-Star if it is called as you can see
here.
And finally and if for this card.
OK.
So if I actually click on the spot in here and as you can see if you have this high stakes here.
OK.
So let's actually change the orientation of our device and let's see what our what if it's the Android
lifecycle are all going to be called.
So first the puzzle if it is called as you can see here and then the and save instance state is called.
And then the unstopped method is called as you can see.
And finally the undestroyed if it is called and again it's going to actually call the uncreate Meffert
as you can see here and then the unstored nefarious card and on list for instance state if it is called
an honorary Z if it is called.
OK.
And as you can see here we can see that's the text here.
So here I want to show you that in order to save our data.
When the device orientation is actually changed we need to actually save our data inside this and save
instance state and we can actually retrieve our data inside this on restore instances.
So insight is unsafe in a sense state.
I can actually save the value that is in sight of this text view here.
So to use hide the set text string value right here I am actually setting the value of this string value
to this and that to the set text Meffert of this takes the high.
OK.
So I want to actually save this value string back to you.
So let's see how we can do that.
Let's go inside this unsafe instance state and here as you can see we have these arguments right which
is of type Bondel save instance that.
So what you want to do here.
Here I want to actually save the value that is actually assigned to these takes you takes the high.
So what is the value that is assigned to the stakes through this string value here as you can see is
actually assigned to this view.
And as you can see here in line 15 inside this main activity class I declared this variable this string
object inside this class.
So I want to save this value when the device orientation is changed and then retrieve that value.
So in order to save this value we need to actually go inside this onstage instance State Mefford here
and here I can actually save that value by referring to this argument that we received as as an argument
here as you can see of the Smurfette from the Smurfit.
I can actually type in save instance state here that's put as he has.
Here we have lots of misfits here put strange point ain't Boullion food.
All put binder put bundle put put bite put bite away.
So if DMF at that I actually am actually interested here is this MF'er put strange.
So this if it accepts two argument the first one is going to be the key that you want to actually assign
for this value that you want to save in memory.
The key is very important because later that you want to retrieve this value.
I need to actually refer to the name of that key in order to retrieve the the actual value.
So I need to put two double quotes here so as you can see here are the data type of this key is is string.
So the key is going to be capitalized and the name of the key is going to be strange value because I
want to actually save the value of the string value value.
OK what you want to save in memory when the device orientation is actually changed.
I want to actually save the value of the string value of value right here as you can see if you have
this string value variable here and in Enceladus this uncle that I am actually assigning this value
high to the string value and in line first 88.
I am actually assigning this value to this set text method of this takes few takes the high.
So I want to save that value string value so I can just refer to the name of that variable string value.
So because I actually declared this valuable inside this class main activity I can refer to the name
of that variable here inside this unsafe instance method.
OK.
So inside this on restore instance state I can actually retrieve that value when the device orientation
is actually changed.
So let me actually once again change the orientation of these are the ways to vertical as you can see
here.
Now you can see the unpause method is called and then the save instance it is called and then the unstopped
if it is caused as you can see here and then the undestroyed Meffert is called.
OK.
And again it's going to cause the uncreate Meffert as you can see and then the unstuffed if it is called
and unrestored instance state if it is called So here we can actually retrieve the data.
Is always thought instances state.
So inside this unrestored instance of state I can try to retrieve the data that I actually saved inside
this and save instance that.
So how can I actually get the data.
So first of all I can I try to refer to the name of that strange value valuable assignment operator.
So I want to actually retrieve that data and assign them again to this variable string value.
So here I just need to refer to the name of this object which is of type bundle that they actually receive
as an argument from the Smurfette.
So here I can't just say I mean save instance state DOT get string.
So you want to get a string value right.
And here I just need to pass the key that I actually sign here that I actually specified inside this
unsafe instance state.
So I just need to copy this key here and put it inside these tabs of course here and at the end of my
statement I need to put a semi-colon.
And here again I just need to refer to the name of this th the high that set text.
And here I can just refer to the name of this value.
But again strange value valuable because I am actually assigning this value to the string value variable
trees string value variable and in line one hundred and four.
I am actually assigning that value to this.
So it takes two of these to actually Heidi.
OK.
So let's run our project again and see what happens.
So now we can see our application is running the uncreate method is called the On-Star.
If it is called as you can see here and then the resume if it is called here and now my application
is actually in the honors you actually state.
OK.
So let's actually click on this button.
Hi.
So let's actually change the orientation of this device.
And now the on pause for this card as you can see and at the same instance it is called.
So here I actually saved the value of this takes unstopped my faith is called undestroyed if it is called.
OK.
And then the uncreate method is called as you can see.
After that the start of it is called.
And finally as you can see here and race for instance the method is called.
So here as you can see when I try to reach retrieving that data.
When the when the actually application is actually changed its orientation and the device is there to
change its orientation.
So now as you can see now is this data is actually safe.
We can see the value of this this view here.
And if I change the orientation again.
Now you can see that the data is actually saved and it's not actually gone.
So hopefully that makes sense and I think that's enough for this whole year.
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 see you in the next the.