1
00:00:00,240 --> 00:00:06,420
The first one is the unsaved instance state and as I can see here you are inheriting this never from

2
00:00:06,420 --> 00:00:12,480
the superclass activity and this if it should accept an argument of type bundle and the name of this

3
00:00:12,630 --> 00:00:19,930
argument is saved instance state and in line 86 we are actually in the supervision of this if it's that

4
00:00:20,030 --> 00:00:27,240
super unsafe instance State save instance that we are passing this argument here and in line 88 we are

5
00:00:27,240 --> 00:00:32,770
actually creating a host object and we want to show dismiss to the user on save instance.

6
00:00:32,810 --> 00:00:33,630
It is called.

7
00:00:33,630 --> 00:00:37,220
So I want to let the user know Vendy Smurfette is actually being called.

8
00:00:37,290 --> 00:00:44,380
And here we have this unrestored instance that as you can see here and again this is actually an effort

9
00:00:44,400 --> 00:00:47,270
that we are inheriting from the superclass.

10
00:00:47,280 --> 00:00:52,750
And as you can see in line 94 you're actually calling it the super version of the Smurfette.

11
00:00:53,070 --> 00:00:58,920
And in 96 I actually created a tossed object in order to let the user know when this method is going

12
00:00:58,920 --> 00:01:03,120
to be called on unrestored instance statement for this card.

13
00:01:03,120 --> 00:01:07,450
So let's run our project and see Wendy's or Android lifecycle.

14
00:01:07,480 --> 00:01:09,050
My efforts are going to be called.

15
00:01:09,150 --> 00:01:12,750
So I hate to hit the run button here and then click on OK.

16
00:01:12,860 --> 00:01:17,870
The uncreate for this called the unstarted if it is called the on resume if it is called Right.

17
00:01:17,880 --> 00:01:22,820
So first the create method is called and then the on if it is called.

18
00:01:22,830 --> 00:01:25,100
And finally the andr's your method is called.

19
00:01:25,110 --> 00:01:29,220
So now our application is actually in the resume state as you can see here.

20
00:01:29,490 --> 00:01:34,720
So now let's actually click on the spot and here and here as you can see we have this high stakes here.

21
00:01:34,740 --> 00:01:35,510
OK.

22
00:01:35,580 --> 00:01:42,510
So let's actually rotate the device rotate right and change the device orientation as you can see here

23
00:01:43,930 --> 00:01:46,570
and now you can see the positive for this card.

24
00:01:46,710 --> 00:01:52,550
And then the save instance is called and unstopped met for this card and undestroyed of this card.

25
00:01:52,710 --> 00:01:54,980
And finally again the uncreate for this card.

26
00:01:54,990 --> 00:01:59,000
And unstarted if it is called and Andreas for instance it is called.

27
00:01:59,010 --> 00:02:02,140
And finally the resume if it is called.

28
00:02:02,190 --> 00:02:08,370
So let me actually go inside these Meffert these are let's create a them if it here as you can see and

29
00:02:08,370 --> 00:02:12,200
change these short to lend long.

30
00:02:12,710 --> 00:02:14,960
And let's run our project again.

31
00:02:15,060 --> 00:02:18,540
Let me get you to change the orientation again to vertical.

32
00:02:18,630 --> 00:02:24,510
First of all the uncreate if it is caught right and then the On-Star if it is called as you can see

33
00:02:24,510 --> 00:02:25,200
here.

34
00:02:25,230 --> 00:02:27,190
And finally and if for this card.

35
00:02:27,240 --> 00:02:27,960
OK.

36
00:02:28,230 --> 00:02:32,220
So if I actually click on the spot in here and as you can see if you have this high stakes here.

37
00:02:32,220 --> 00:02:32,790
OK.

38
00:02:32,820 --> 00:02:39,150
So let's actually change the orientation of our device and let's see what our what if it's the Android

39
00:02:39,150 --> 00:02:41,810
lifecycle are all going to be called.

40
00:02:42,600 --> 00:02:49,530
So first the puzzle if it is called as you can see here and then the and save instance state is called.

41
00:02:50,130 --> 00:02:53,060
And then the unstopped method is called as you can see.

42
00:02:53,310 --> 00:02:58,230
And finally the undestroyed if it is called and again it's going to actually call the uncreate Meffert

43
00:02:58,290 --> 00:03:06,690
as you can see here and then the unstored nefarious card and on list for instance state if it is called

44
00:03:07,200 --> 00:03:09,210
an honorary Z if it is called.

45
00:03:09,630 --> 00:03:10,780
OK.

46
00:03:10,890 --> 00:03:13,620
And as you can see here we can see that's the text here.

47
00:03:13,620 --> 00:03:17,860
So here I want to show you that in order to save our data.

48
00:03:17,940 --> 00:03:24,060
When the device orientation is actually changed we need to actually save our data inside this and save

49
00:03:24,060 --> 00:03:30,780
instance state and we can actually retrieve our data inside this on restore instances.

50
00:03:31,120 --> 00:03:33,710
So insight is unsafe in a sense state.

51
00:03:33,800 --> 00:03:39,670
I can actually save the value that is in sight of this text view here.

52
00:03:39,750 --> 00:03:46,710
So to use hide the set text string value right here I am actually setting the value of this string value

53
00:03:46,950 --> 00:03:50,480
to this and that to the set text Meffert of this takes the high.

54
00:03:50,580 --> 00:03:51,120
OK.

55
00:03:51,360 --> 00:03:54,290
So I want to actually save this value string back to you.

56
00:03:54,480 --> 00:03:56,070
So let's see how we can do that.

57
00:03:56,070 --> 00:04:01,510
Let's go inside this unsafe instance state and here as you can see we have these arguments right which

58
00:04:01,510 --> 00:04:04,400
is of type Bondel save instance that.

59
00:04:04,410 --> 00:04:06,350
So what you want to do here.

60
00:04:06,540 --> 00:04:13,010
Here I want to actually save the value that is actually assigned to these takes you takes the high.

61
00:04:13,050 --> 00:04:17,330
So what is the value that is assigned to the stakes through this string value here as you can see is

62
00:04:17,340 --> 00:04:19,350
actually assigned to this view.

63
00:04:19,530 --> 00:04:26,100
And as you can see here in line 15 inside this main activity class I declared this variable this string

64
00:04:26,130 --> 00:04:27,640
object inside this class.

65
00:04:27,810 --> 00:04:33,950
So I want to save this value when the device orientation is changed and then retrieve that value.

66
00:04:34,140 --> 00:04:40,010
So in order to save this value we need to actually go inside this onstage instance State Mefford here

67
00:04:40,170 --> 00:04:45,660
and here I can actually save that value by referring to this argument that we received as as an argument

68
00:04:45,660 --> 00:04:48,430
here as you can see of the Smurfette from the Smurfit.

69
00:04:48,600 --> 00:04:55,720
I can actually type in save instance state here that's put as he has.

70
00:04:55,720 --> 00:05:00,770
Here we have lots of misfits here put strange point ain't Boullion food.

71
00:05:00,820 --> 00:05:05,850
All put binder put bundle put put bite put bite away.

72
00:05:05,920 --> 00:05:10,800
So if DMF at that I actually am actually interested here is this MF'er put strange.

73
00:05:11,200 --> 00:05:18,220
So this if it accepts two argument the first one is going to be the key that you want to actually assign

74
00:05:18,490 --> 00:05:22,080
for this value that you want to save in memory.

75
00:05:22,090 --> 00:05:25,800
The key is very important because later that you want to retrieve this value.

76
00:05:25,900 --> 00:05:31,360
I need to actually refer to the name of that key in order to retrieve the the actual value.

77
00:05:31,420 --> 00:05:37,710
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.

78
00:05:37,930 --> 00:05:44,590
So the key is going to be capitalized and the name of the key is going to be strange value because I

79
00:05:44,590 --> 00:05:48,060
want to actually save the value of the string value value.

80
00:05:48,110 --> 00:05:52,210
OK what you want to save in memory when the device orientation is actually changed.

81
00:05:52,510 --> 00:05:58,510
I want to actually save the value of the string value of value right here as you can see if you have

82
00:05:58,510 --> 00:06:03,610
this string value variable here and in Enceladus this uncle that I am actually assigning this value

83
00:06:03,610 --> 00:06:06,890
high to the string value and in line first 88.

84
00:06:06,910 --> 00:06:11,770
I am actually assigning this value to this set text method of this takes few takes the high.

85
00:06:11,880 --> 00:06:19,480
So I want to save that value string value so I can just refer to the name of that variable string value.

86
00:06:19,510 --> 00:06:26,650
So because I actually declared this valuable inside this class main activity I can refer to the name

87
00:06:26,650 --> 00:06:31,200
of that variable here inside this unsafe instance method.

88
00:06:31,420 --> 00:06:32,080
OK.

89
00:06:32,440 --> 00:06:38,950
So inside this on restore instance state I can actually retrieve that value when the device orientation

90
00:06:38,950 --> 00:06:40,060
is actually changed.

91
00:06:40,300 --> 00:06:47,830
So let me actually once again change the orientation of these are the ways to vertical as you can see

92
00:06:47,830 --> 00:06:48,270
here.

93
00:06:48,280 --> 00:06:55,510
Now you can see the unpause method is called and then the save instance it is called and then the unstopped

94
00:06:55,550 --> 00:06:59,880
if it is caused as you can see here and then the undestroyed Meffert is called.

95
00:06:59,920 --> 00:07:00,720
OK.

96
00:07:00,850 --> 00:07:06,760
And again it's going to cause the uncreate Meffert as you can see and then the unstuffed if it is called

97
00:07:08,280 --> 00:07:13,040
and unrestored instance state if it is called So here we can actually retrieve the data.

98
00:07:13,240 --> 00:07:15,260
Is always thought instances state.

99
00:07:15,390 --> 00:07:21,290
So inside this unrestored instance of state I can try to retrieve the data that I actually saved inside

100
00:07:21,300 --> 00:07:23,820
this and save instance that.

101
00:07:23,910 --> 00:07:25,740
So how can I actually get the data.

102
00:07:25,890 --> 00:07:32,810
So first of all I can I try to refer to the name of that strange value valuable assignment operator.

103
00:07:32,820 --> 00:07:38,420
So I want to actually retrieve that data and assign them again to this variable string value.

104
00:07:38,430 --> 00:07:44,100
So here I just need to refer to the name of this object which is of type bundle that they actually receive

105
00:07:44,100 --> 00:07:45,790
as an argument from the Smurfette.

106
00:07:45,870 --> 00:07:52,850
So here I can't just say I mean save instance state DOT get string.

107
00:07:52,880 --> 00:07:54,650
So you want to get a string value right.

108
00:07:54,830 --> 00:08:01,400
And here I just need to pass the key that I actually sign here that I actually specified inside this

109
00:08:01,700 --> 00:08:03,320
unsafe instance state.

110
00:08:03,320 --> 00:08:08,870
So I just need to copy this key here and put it inside these tabs of course here and at the end of my

111
00:08:08,870 --> 00:08:11,240
statement I need to put a semi-colon.

112
00:08:11,600 --> 00:08:16,790
And here again I just need to refer to the name of this th the high that set text.

113
00:08:17,240 --> 00:08:19,480
And here I can just refer to the name of this value.

114
00:08:19,520 --> 00:08:25,780
But again strange value valuable because I am actually assigning this value to the string value variable

115
00:08:25,900 --> 00:08:29,030
trees string value variable and in line one hundred and four.

116
00:08:29,070 --> 00:08:31,920
I am actually assigning that value to this.

117
00:08:32,020 --> 00:08:34,570
So it takes two of these to actually Heidi.

118
00:08:34,580 --> 00:08:35,590
OK.

119
00:08:36,080 --> 00:08:38,900
So let's run our project again and see what happens.

120
00:08:38,960 --> 00:08:43,880
So now we can see our application is running the uncreate method is called the On-Star.

121
00:08:43,880 --> 00:08:51,170
If it is called as you can see here and then the resume if it is called here and now my application

122
00:08:51,170 --> 00:08:54,520
is actually in the honors you actually state.

123
00:08:54,560 --> 00:08:55,180
OK.

124
00:08:55,190 --> 00:08:56,550
So let's actually click on this button.

125
00:08:56,570 --> 00:08:58,010
Hi.

126
00:08:58,010 --> 00:09:00,980
So let's actually change the orientation of this device.

127
00:09:00,980 --> 00:09:06,800
And now the on pause for this card as you can see and at the same instance it is called.

128
00:09:06,800 --> 00:09:13,120
So here I actually saved the value of this takes unstopped my faith is called undestroyed if it is called.

129
00:09:13,160 --> 00:09:13,930
OK.

130
00:09:14,390 --> 00:09:18,460
And then the uncreate method is called as you can see.

131
00:09:18,620 --> 00:09:20,980
After that the start of it is called.

132
00:09:21,290 --> 00:09:25,380
And finally as you can see here and race for instance the method is called.

133
00:09:25,400 --> 00:09:29,400
So here as you can see when I try to reach retrieving that data.

134
00:09:29,680 --> 00:09:34,600
When the when the actually application is actually changed its orientation and the device is there to

135
00:09:34,590 --> 00:09:36,210
change its orientation.

136
00:09:36,230 --> 00:09:40,410
So now as you can see now is this data is actually safe.

137
00:09:40,430 --> 00:09:42,770
We can see the value of this this view here.

138
00:09:42,920 --> 00:09:45,370
And if I change the orientation again.

139
00:09:45,710 --> 00:09:50,750
Now you can see that the data is actually saved and it's not actually gone.

140
00:09:50,750 --> 00:09:55,960
So hopefully that makes sense and I think that's enough for this whole year.

141
00:09:55,970 --> 00:10:01,100
So if you have any questions please post the discussion in the course and then I'll do my best to answer

142
00:10:01,430 --> 00:10:02,810
all of your questions.

143
00:10:02,810 --> 00:10:04,000
Thank you very much for watching.

144
00:10:04,000 --> 00:10:05,450
And I see you in the next the.

