1
00:00:00,270 --> 00:00:06,460
Hi everyone in this theater they are really going to go ahead and create another Android application.

2
00:00:06,480 --> 00:00:07,440
So just click on these.

3
00:00:07,500 --> 00:00:13,920
Start in your Android studio project and then for the name of your application just type in here app

4
00:00:14,520 --> 00:00:24,330
or 56 and then click on sit next and here choose AP 16 Android 4.1 Villepin and then click on next and

5
00:00:24,330 --> 00:00:28,510
here choose empty activity next and he can finish.

6
00:00:28,830 --> 00:00:32,550
So now as you can see here our project is actually created.

7
00:00:32,640 --> 00:00:37,560
So let's actually double click on this and this folder here and then click on this lay out the directory

8
00:00:37,650 --> 00:00:41,710
and then DoubleClick and this activity underline made that example here.

9
00:00:41,910 --> 00:00:47,050
So now as you can see here now we want to actually design the user interface of our application so that

10
00:00:47,050 --> 00:00:51,930
naturally select is hell over here and then press on delivery on your keyboard.

11
00:00:51,930 --> 00:00:57,330
So now let's actually drive our linearly vertical into these relatively out here.

12
00:00:57,360 --> 00:01:03,210
So just select is linearly as well as the cut and put it at the center of this relatively out here and

13
00:01:03,210 --> 00:01:08,520
then let's actually drag out a large takes you into these linearly as vertical.

14
00:01:08,520 --> 00:01:15,180
So just select is large the view here and put it at the center of this linearly as vertical and then

15
00:01:15,240 --> 00:01:21,750
double click and it takes you here and then read the text of this takes you and for the ID to step in

16
00:01:21,750 --> 00:01:24,320
here takes the high.

17
00:01:24,590 --> 00:01:25,200
OK.

18
00:01:25,290 --> 00:01:27,920
And then press Enter key on your keyboard.

19
00:01:27,930 --> 00:01:34,200
So now this entry to the right button into this linearly as vertical and put it below these takes you.

20
00:01:34,200 --> 00:01:41,250
And at the center of this nearly 20 COL W any spot in here and for the text just type in here.

21
00:01:41,250 --> 00:01:41,840
Hi.

22
00:01:42,180 --> 00:01:49,060
And for the ID just type in here between high and then press on until key on your keyboard.

23
00:01:49,350 --> 00:01:52,410
So another design about user interface is actually finished.

24
00:01:52,410 --> 00:01:54,850
So let's go back to what main activity that have a file here.

25
00:01:55,080 --> 00:01:58,750
And now let's actually create some objects here.

26
00:01:58,860 --> 00:02:03,780
So the first object that I want to actually declare here is going to be a text view object and the name

27
00:02:03,780 --> 00:02:09,560
of my object is going to be tasty high and then I need to put a semicolon at the end of my statement.

28
00:02:09,930 --> 00:02:14,880
And the second object is going to be of a button and the name of my object is going to be pretty high.

29
00:02:15,090 --> 00:02:17,970
And then I need to put a semi-colon at the end of my statement.

30
00:02:18,000 --> 00:02:19,680
So inside is uncreate Meffert.

31
00:02:19,680 --> 00:02:22,950
Now able want to actually instantiate these two objects.

32
00:02:23,250 --> 00:02:27,620
The first one is going to BTX the high assignment operator.

33
00:02:27,810 --> 00:02:38,040
And then I need to cast this object to a text view object find view by id r r that ID that takes the

34
00:02:38,130 --> 00:02:43,950
high and then I need to put a semicolon at the end of my statement and the second one is going to be

35
00:02:43,950 --> 00:02:46,460
Pythian high assignment operator.

36
00:02:46,710 --> 00:02:55,260
And then I need to cast this object to a button object find view by ID or ID that PTEN ID that pretty

37
00:02:55,450 --> 00:02:56,100
high.

38
00:02:56,310 --> 00:02:59,840
And then I need to put a semicolon at the end of my statement.

39
00:02:59,880 --> 00:03:03,490
So now I want to actually make the spot and a listener to the police of the user.

40
00:03:03,510 --> 00:03:10,620
So here I can just type in between and high that said Uncle listener and that I need to actually pass

41
00:03:10,620 --> 00:03:11,430
the context.

42
00:03:11,430 --> 00:03:16,620
So the context is going through the main activity that this and and here at the top I need to actually

43
00:03:16,620 --> 00:03:21,560
implement so implements on the the view that unclick listener interface.

44
00:03:21,660 --> 00:03:25,430
So if you start unclick listener.

45
00:03:26,230 --> 00:03:32,180
OK so now I need to actually overwrite the and Meffert that is actually inside of this unclick isn't

46
00:03:32,220 --> 00:03:32,930
an interface.

47
00:03:32,940 --> 00:03:38,210
So here I can just point and click and then I need to press press Enter key on my keyboard.

48
00:03:38,340 --> 00:03:41,800
So as you can see here the ankle my foot is actually over right here.

49
00:03:41,940 --> 00:03:45,320
So this actually changed its name to view the arguments name to view.

50
00:03:45,660 --> 00:03:53,410
And now I want to actually put some of the Android lifecycle MFX here and I want to actually show you

51
00:03:53,560 --> 00:03:57,110
a really important point about the Android lifecycle.

52
00:03:57,260 --> 00:03:57,990
OK.

53
00:03:58,290 --> 00:04:03,550
So first of all let's actually create a string value or something valuable insight.

54
00:04:03,570 --> 00:04:04,930
Our main activity class.

55
00:04:05,010 --> 00:04:10,010
So here inside our main activity class here I just need to create a string variable.

56
00:04:10,080 --> 00:04:14,520
So here I just need to refer to the name of this string class and the name of my variable is going to

57
00:04:14,520 --> 00:04:16,180
be strange value.

58
00:04:16,670 --> 00:04:17,210
OK.

59
00:04:17,520 --> 00:04:24,460
And I need to put a semicolon here at the end of my statement and then here are inside our unclick Mefford

60
00:04:24,790 --> 00:04:25,130
here.

61
00:04:25,200 --> 00:04:28,240
I want to actually initialize this variable.

62
00:04:28,590 --> 00:04:31,200
So here I can just type in a string value.

63
00:04:31,350 --> 00:04:35,880
I just need to refer to the name of this rally or with the name of this object as you can see here setting

64
00:04:35,910 --> 00:04:37,380
value assignment operator.

65
00:04:37,560 --> 00:04:41,280
And here I can assign the value high to this body.

66
00:04:41,310 --> 00:04:42,930
Okay to this object.

67
00:04:42,930 --> 00:04:52,960
And now I can just type in here again just typing ATX the high data set text string value.

68
00:04:53,310 --> 00:05:00,180
So now I want to actually assign the value of this string value valuable to this takes the high as you

69
00:05:00,180 --> 00:05:00,820
can see here.

70
00:05:00,960 --> 00:05:06,380
I want to assign the value of the string value variable to listen to this RTX the high stakes the high

71
00:05:06,380 --> 00:05:08,190
that set text string value.

72
00:05:08,190 --> 00:05:10,940
So now let's actually run our project and see what happens.

73
00:05:11,100 --> 00:05:15,520
So here as you can see our application is running on the simulator here.

74
00:05:15,540 --> 00:05:21,480
So if I click on the spot in here lets see what happens soon as I can see we have this value here high.

75
00:05:21,600 --> 00:05:23,190
Ok for the state's view.

76
00:05:23,190 --> 00:05:26,290
So this actually rotate the device and see what happens.

77
00:05:26,400 --> 00:05:28,810
So just click on this rotate right here.

78
00:05:29,830 --> 00:05:32,280
And now as you can see this value is gone.

79
00:05:32,430 --> 00:05:32,810
OK.

80
00:05:32,890 --> 00:05:34,170
So what's going on here.

81
00:05:34,330 --> 00:05:41,050
So we have a very big problem here vended device is actually rotated on many devices actually in the

82
00:05:41,770 --> 00:05:43,100
landscape mode.

83
00:05:43,270 --> 00:05:43,930
OK.

84
00:05:43,960 --> 00:05:46,280
The Andi's treatment for it is going to be called.

85
00:05:46,300 --> 00:05:50,930
So for example now as you can see the device is actually in the portrait mode right.

86
00:05:51,100 --> 00:05:55,350
And now I want to actually see my application in the landscape.

87
00:05:55,390 --> 00:05:58,330
So if I click on this rotate right button here.

88
00:05:58,330 --> 00:06:01,620
Now my application is actually in the landscape mode.

89
00:06:01,810 --> 00:06:09,910
And when the device is going to actually change its orientation or for example from vertical to horizontal

90
00:06:09,910 --> 00:06:15,330
or from horizontal to vertical the undestroyed Murphy is going to be called and undestroyed move it

91
00:06:15,340 --> 00:06:18,330
is going to be called the application is going to be destroyed.

92
00:06:18,540 --> 00:06:18,810
OK.

93
00:06:18,850 --> 00:06:25,870
And that means that we are valuable as the value of our valuables are going to be actually empty and

94
00:06:25,900 --> 00:06:30,590
we can see that we cannot see now the value of this takes here.

95
00:06:30,610 --> 00:06:36,480
So if I click on this high button here again and and if I actually change the orientation of this device

96
00:06:36,490 --> 00:06:39,900
now by clicking on this rotate left here.

97
00:06:39,910 --> 00:06:43,580
Now as you can see the value of these tapes is gone.

98
00:06:43,630 --> 00:06:45,670
So we need to save this value.

99
00:06:45,670 --> 00:06:50,940
The value of that takes you up before the app the application is actually completely destroyed.

100
00:06:51,100 --> 00:06:57,930
So let me actually paste in some other Android lifecycle if it's here and then it'll make sense to you.

101
00:06:57,940 --> 00:07:03,640
So now after the creation of this article each method here as you can see inside this main activity

102
00:07:03,640 --> 00:07:09,430
class I'm going to paste in some lines of code here and then I'm going to explain to you what's going

103
00:07:09,430 --> 00:07:10,740
on here.

104
00:07:10,780 --> 00:07:16,040
So as you can see here these are the lines of code that are actually pasted here.

105
00:07:16,060 --> 00:07:16,540
OK.

106
00:07:16,720 --> 00:07:19,540
So first of all let me explain to you what's going on here.

107
00:07:19,720 --> 00:07:23,530
So I ask here first about I actually place that this method here.

108
00:07:23,590 --> 00:07:28,130
So the access modifier of this method is public.

109
00:07:28,360 --> 00:07:33,650
The return type of this method is void and the name of this method is let's create a toast.

110
00:07:33,760 --> 00:07:34,260
OK.

111
00:07:34,480 --> 00:07:39,460
So the job of this method is to actually create a toast and a short that goes to the user.

112
00:07:39,460 --> 00:07:45,720
And this method actually accepts an argument of type strange and the name of this argument is message.

113
00:07:45,760 --> 00:07:46,230
OK.

114
00:07:46,390 --> 00:07:52,090
So inside this method as you can see inside the curly braces of this method I actually created a host

115
00:07:52,090 --> 00:07:52,600
object.

116
00:07:52,660 --> 00:07:56,940
So you referred to the name of this TOSed class that makes text.

117
00:07:57,070 --> 00:08:02,560
First of all I actually passed the context main activity that this the second argument is going to be

118
00:08:02,560 --> 00:08:04,880
the message that I want to show to the user.

119
00:08:04,960 --> 00:08:10,120
So the message is going to be the argument that it's going to be passed to dismiss it.

120
00:08:10,120 --> 00:08:15,610
Let's create a toast and a fresh argument is going to be and the failed argument is going to be the

121
00:08:15,610 --> 00:08:18,480
length that is going to be shown to the user.

122
00:08:18,640 --> 00:08:23,230
And finally what I'm actually calling this show Mefford on this object.

123
00:08:23,290 --> 00:08:23,530
OK.

124
00:08:23,530 --> 00:08:26,590
So that this toast is going to be shown to the user.

125
00:08:26,620 --> 00:08:30,110
So as you can see here these are the Android lifecycle methods.

126
00:08:30,130 --> 00:08:34,780
For example the uncreate Mefford is actually an android lifecycle Meffert.

127
00:08:34,780 --> 00:08:40,720
So let's actually create a toast inside this uncreate Meffert in order to let the user know when the

128
00:08:40,720 --> 00:08:42,350
uncreate if it is actually called.

129
00:08:42,400 --> 00:08:45,950
Ok so here I can just refer to that to the name of this.

130
00:08:46,080 --> 00:08:47,520
Let's create a two Smurfette.

131
00:08:47,540 --> 00:08:49,570
Inside these uncreate method.

132
00:08:49,690 --> 00:08:57,550
So let's create a toast and for the message I need to pass the message that I want to show to the user

133
00:08:57,820 --> 00:09:12,570
so I can just type in the on create the create method is called Ok it's called.

134
00:09:12,880 --> 00:09:15,330
So I just put this Meffert here.

135
00:09:15,340 --> 00:09:20,410
Let's create a toast and then I actually put this message in order to show to the user that the uncreate

136
00:09:20,420 --> 00:09:23,380
method is actually called Inside this uncreate method.

137
00:09:23,500 --> 00:09:28,380
And the next Android lifecycle Meffert is actually the Smurfette on start Moffet.

138
00:09:28,380 --> 00:09:30,820
So after this method here let's create a toss.

139
00:09:30,970 --> 00:09:33,990
I actually pasted this method here on a start.

140
00:09:34,000 --> 00:09:37,290
So as you can see here the axis modifier of this method is protected.

141
00:09:37,450 --> 00:09:42,910
OK so you are actually inheriting this Smurfette from the superclass which is activity and as you can

142
00:09:42,910 --> 00:09:44,610
see here we are all writing this class.

143
00:09:44,620 --> 00:09:45,060
OK.

144
00:09:45,220 --> 00:09:50,920
So the return type of the Smurfette is void and the name of this is unstuffed so honest thought Meffert

145
00:09:50,920 --> 00:09:55,190
is going to be called after the uncreate method as you can see here.

146
00:09:55,210 --> 00:10:00,700
So inside this unstarted effort as you can see first that what I am actually calling the super version

147
00:10:00,700 --> 00:10:07,060
of the Smurfette Superlight on a slot and then in line 53 I am actually creating a tossed object in

148
00:10:07,060 --> 00:10:12,850
order to show to the user that that Vendy unstarted if it is going to be called an honest start.

149
00:10:12,850 --> 00:10:20,190
If it is going to be called after the uncreate Smurfit so after the unstarted if it is called the on

150
00:10:20,230 --> 00:10:25,900
resume if it is going to be called ok as you can see here again we are inheriting this Merfeld from

151
00:10:25,900 --> 00:10:33,160
the activity class and here as you can see in line fifty fifty eight you are actually calling the supervision

152
00:10:33,370 --> 00:10:39,010
of the Smurfette superdad and raising of my fifth and in line 60 you are actually creating an object

153
00:10:39,210 --> 00:10:42,440
or a host object in order to show to the user.

154
00:10:42,460 --> 00:10:46,770
So let's create a toast and resume if it is called as you can see here.

155
00:10:47,170 --> 00:10:51,100
And then as you can see here on here we have these on plasma.

156
00:10:51,280 --> 00:10:57,340
So if the user clicks that clicks on the back button on the device or if the user for example switches

157
00:10:57,340 --> 00:11:02,680
between the applications the unpeeled the unplausible if it is going to be called as you can see here.

158
00:11:02,680 --> 00:11:07,420
So as you can see here again we are actually creating a host object in order to let the user know when

159
00:11:07,420 --> 00:11:09,340
they are unpause if it is called.

160
00:11:09,850 --> 00:11:12,350
And as you can see here we have this unstopped Meffert.

161
00:11:12,580 --> 00:11:17,890
So after the unpause Mefford for example when the user clicks on the back button on the device at the

162
00:11:17,980 --> 00:11:20,090
first level the positive it is going to be called.

163
00:11:20,140 --> 00:11:22,740
And then the unstopped if it is going to be called.

164
00:11:22,810 --> 00:11:27,990
Ok so here we are actually creating a tossed object in order to show to the user this message.

165
00:11:28,150 --> 00:11:31,750
Honestly if it is called and then we have these on these three MF'er.

166
00:11:31,750 --> 00:11:38,620
So this is going to be called of any application is actually destroyed from the memory and the information

167
00:11:38,950 --> 00:11:41,690
inside the application is actually completely gone.

168
00:11:41,860 --> 00:11:46,810
So as you can see I am actually creating a host object in order to let the user know that Vendy on the

169
00:11:46,810 --> 00:11:50,790
stream if it is called and here we have two new methods.

170
00:11:50,900 --> 00:11:57,390
OK you already saw these methods in the previous tutorials and actually talked about Android lifecycle

171
00:11:57,400 --> 00:11:57,960
methods.

172
00:11:58,090 --> 00:12:03,430
But these two methods are actually two new methods that of the Android lifecycle that I want to talk

173
00:12:03,430 --> 00:12:04,660
about in this tutorial.

