1
00:00:00,240 --> 00:00:06,300
Hyas the audience in this theater we're going to go ahead and create another Android application and

2
00:00:06,330 --> 00:00:09,240
connect our application to the firebase database.

3
00:00:09,240 --> 00:00:15,210
So now let's create an android studio project and then here for the application and just typing here

4
00:00:15,240 --> 00:00:24,260
at 65 and then click on next and he chews API 16 Android 4.1 jellybean for the minimum for the minimum

5
00:00:24,270 --> 00:00:32,090
STK and then click on next and here choose empty activity next and here don't change anything.

6
00:00:32,250 --> 00:00:37,110
So make sure that the activity name is main activity and the layout name is actually with the underlying

7
00:00:37,110 --> 00:00:37,700
main.

8
00:00:38,040 --> 00:00:39,970
So it's going to generate a file.

9
00:00:40,140 --> 00:00:45,340
And that backwards compatibility is enabled and then click can finish.

10
00:00:45,360 --> 00:00:47,260
So let's actually wait a little bit here.

11
00:00:47,280 --> 00:00:52,170
So first of all we need to actually connect our application to the firebase database.

12
00:00:52,230 --> 00:00:58,620
So at the top as you can see here just click on Tools and then click on firebase and now it can actually

13
00:00:58,620 --> 00:01:01,380
open the fireplace assistant here for us.

14
00:01:01,560 --> 00:01:08,110
So let's actually click on this real time database and then click on this save and retrieve data.

15
00:01:08,490 --> 00:01:13,480
And now for the first step we just need to connect our application to the fireplace.

16
00:01:13,530 --> 00:01:17,310
So just click on this button here connect to firebase.

17
00:01:17,310 --> 00:01:18,850
So let's wait a little bit here.

18
00:01:18,900 --> 00:01:22,650
As you can see it's SISC start connect starting connect dialog.

19
00:01:22,800 --> 00:01:23,630
Right.

20
00:01:23,880 --> 00:01:28,060
Now as you can see here that this window is open for us.

21
00:01:28,260 --> 00:01:32,660
And now I just need to actually specify the name of the project.

22
00:01:32,700 --> 00:01:35,850
And here it is create new firebase project right.

23
00:01:35,880 --> 00:01:41,580
So if you want to connect your application to an already created a project you just need to check the

24
00:01:41,640 --> 00:01:48,180
checkbox and choose an existing firebase or Google project and then you can actually connect your application

25
00:01:48,480 --> 00:01:50,620
to one of your projects in firebase.

26
00:01:50,830 --> 00:01:57,750
But for now we just want to create a new project right so that we can create new firebase project and

27
00:01:57,750 --> 00:02:02,100
the name is at 65 and they can connect to firebase.

28
00:02:02,100 --> 00:02:04,080
So let's wait a little bit here.

29
00:02:04,140 --> 00:02:08,160
So now as you can see here our project is actually connected to Firebrace.

30
00:02:08,190 --> 00:02:08,810
Right.

31
00:02:08,880 --> 00:02:13,920
So now we should do the second step and it says at a real time database to your app.

32
00:02:13,920 --> 00:02:18,550
So just click on the Spartan and in here or just accept changes here.

33
00:02:18,560 --> 00:02:24,970
Just click on this access changes and it can actually add real time database to our application.

34
00:02:25,020 --> 00:02:26,780
So let's wait a little bit here.

35
00:02:28,070 --> 00:02:37,360
And now as you can see here is actually making our project ready for interacting with the firebase database.

36
00:02:37,460 --> 00:02:44,240
So and as you can see here our project is now ready and here it says dependences set up correctly right.

37
00:02:44,300 --> 00:02:50,380
So now let me collapse this assistant area and now let's actually DoubleClick and this is all they're

38
00:02:50,390 --> 00:02:53,570
here and then doubleclick on its layout folder.

39
00:02:53,570 --> 00:02:57,740
And now DoubleClick and this activity under the last minute example.

40
00:02:57,740 --> 00:03:03,450
So now as you can see here we should actually design the user interface of our application.

41
00:03:03,500 --> 00:03:07,700
So now let me double click on this tab here activity on the line I mean are they similar in order to

42
00:03:07,700 --> 00:03:13,340
make this area wider and now less selectees hello world takes you here and now you want to design the

43
00:03:13,340 --> 00:03:15,040
user interface of our application.

44
00:03:15,050 --> 00:03:21,950
So here first of all let's actually click on this take step here at the bottom Atkins here we have this

45
00:03:22,310 --> 00:03:25,000
Design tab and we have this text up.

46
00:03:25,010 --> 00:03:30,960
So just click on this take step and now this actually change this relatively out to linear layout.

47
00:03:31,160 --> 00:03:39,020
So just select is relatively here and just type in here linearly out with capital L and now as you can

48
00:03:39,020 --> 00:03:43,840
see as you can see here at the bottom it actually changed this name to linearly out.

49
00:03:44,060 --> 00:03:49,470
And now we need to specify the orientation of our linearly out because we have linearly.

50
00:03:49,520 --> 00:03:53,840
Now we should actually specify an orientation for this linear out.

51
00:03:53,870 --> 00:03:56,240
So here's distopian orientation.

52
00:03:56,240 --> 00:03:59,640
So before the ending tag just type in orientation.

53
00:03:59,640 --> 00:04:03,000
And now as you can see you can select this orientation attribute.

54
00:04:03,080 --> 00:04:04,740
And here we have two options.

55
00:04:04,850 --> 00:04:07,880
The first one is vertical and the second one is horizontal.

56
00:04:08,120 --> 00:04:12,960
So for this project I want this vertical orientation for my linearly.

57
00:04:13,040 --> 00:04:16,010
So just select it and then it's an interactive on your keyboard.

58
00:04:16,410 --> 00:04:18,840
And now let's go back to our Design tab.

59
00:04:19,190 --> 00:04:24,470
And as you can see here inside this componentry section we have actually a linearly out vertical line

60
00:04:24,530 --> 00:04:25,110
right.

61
00:04:25,370 --> 00:04:29,180
So first let's actually drag it textfield.

62
00:04:29,330 --> 00:04:35,620
So inside takes wheels fall there it it takes it right just selectees plain text here and just track

63
00:04:35,620 --> 00:04:38,510
it here into this linear layout vertical.

64
00:04:38,930 --> 00:04:42,950
And now just select this text field here.

65
00:04:43,190 --> 00:04:51,260
And for the idea just step in here it is the box Boxer name and that person energy on your keyboard.

66
00:04:51,650 --> 00:04:54,040
And here as you can see we have this text attribute.

67
00:04:54,050 --> 00:04:58,190
So just select this text value here and then delete this value.

68
00:04:58,490 --> 00:05:00,880
And for the hint attribute to saving here.

69
00:05:00,890 --> 00:05:08,960
Enter Boxer name dot dot dot and in person Enter key on your keyboard.

70
00:05:09,050 --> 00:05:13,350
So Alice actually write another textfield into this linearly elsewhere.

71
00:05:13,520 --> 00:05:19,310
So inside distastefulness Well it just select is plain text here and just drag it into this linearly

72
00:05:19,460 --> 00:05:20,490
vertical.

73
00:05:20,960 --> 00:05:23,200
And now for the idea just step in here.

74
00:05:23,240 --> 00:05:30,240
EDT Boxer punch power.

75
00:05:31,030 --> 00:05:33,600
Right and then present energy on your keyboard.

76
00:05:33,730 --> 00:05:37,900
So for the text attributes it disvalue and for the hint just they've been here.

77
00:05:37,900 --> 00:05:44,260
Enter punch power dot dot dot.

78
00:05:44,470 --> 00:05:46,940
And in person until he on your keyboard.

79
00:05:46,950 --> 00:05:50,790
And now it's actually a drag and either a plain text here.

80
00:05:50,830 --> 00:05:56,390
This Titchfield into this linearly as vertical just select it and put it inside this linearly elsewhere

81
00:05:56,400 --> 00:06:07,080
SD card and for the ID just step in here EDT Boxford punch speed and then press on until June your keyboard

82
00:06:07,570 --> 00:06:10,690
and for the name attribute the list disvalue here.

83
00:06:10,840 --> 00:06:13,480
And for the for the hint attribute the statement here.

84
00:06:13,480 --> 00:06:21,650
Enter punch speed dot dot dot and then person enter here on your keyboard.

85
00:06:22,000 --> 00:06:27,100
So now let's actually drag about him into this linearly Ellsworthy called Enceladus which is what a

86
00:06:27,170 --> 00:06:32,050
just spot in here and just drag it here into this linearly as vertical.

87
00:06:32,100 --> 00:06:40,390
Here below this textfield here and slaty spot in and for the ID just type in here between sent data

88
00:06:41,500 --> 00:06:43,750
and then present Enter key on your keyboard.

89
00:06:43,960 --> 00:06:53,330
And for the text attribute to step in here sent data to server and then person Enter key on your keyboard.

90
00:06:53,770 --> 00:06:59,330
And now let's actually write up a vertical scroll view into this linearly.

91
00:06:59,320 --> 00:07:00,200
I swear to god.

92
00:07:00,400 --> 00:07:07,120
So just scroll down here inside the pallet section as you can see inside these containers fall there

93
00:07:07,240 --> 00:07:14,350
as you can see just select this vertical scroll view here as you can see here to selected and dragged

94
00:07:14,350 --> 00:07:21,680
into this linearly or 30 call and now inside these componentry section we have this scroll view and

95
00:07:21,680 --> 00:07:24,380
inside this scroll view we have this linear area as well.

96
00:07:24,390 --> 00:07:25,450
All right.

97
00:07:25,460 --> 00:07:29,740
Just a selectees linearly out vertical here as you can see here.

98
00:07:29,960 --> 00:07:34,680
Just an inside the palette section select is text view here right.

99
00:07:34,680 --> 00:07:40,520
Select it and just drank it here into this linearly at vertical that is inside this scroll of view here

100
00:07:41,450 --> 00:07:45,650
and now inside is linearly vertical that is inside of these scroll view.

101
00:07:45,720 --> 00:07:47,850
We have this takes you right.

102
00:07:48,170 --> 00:07:56,300
And for that for the id attribute of these takes you to step in here takes the received data and in

103
00:07:56,300 --> 00:08:01,880
person and hit on your keyboard and just delete the text attribute as you can see here just delete the

104
00:08:01,880 --> 00:08:06,000
value of this text attribute here and then person enter on your keyboard.

105
00:08:06,080 --> 00:08:10,000
So now that we designed the user interface of our application.

106
00:08:10,130 --> 00:08:14,930
So now let's actually go back to our main activity that double file here and now we can actually put

107
00:08:15,200 --> 00:08:16,830
our own logic's here.

108
00:08:17,060 --> 00:08:23,510
First of all let's actually create a new class so that is at the top just click on view to Windows and

109
00:08:23,510 --> 00:08:24,940
then click on Project.

110
00:08:25,280 --> 00:08:32,230
And here in this app folder and then I work on this job of all that and he has doubleclick on this package.

111
00:08:32,390 --> 00:08:37,160
And here at the top click on File New and then click on Dobber class.

112
00:08:37,160 --> 00:08:43,470
So for the name of our job a class just type in here Puck said with chapiter B and it actually can.

113
00:08:43,510 --> 00:08:44,240
OK.

114
00:08:44,600 --> 00:08:48,460
Soon as you can see here now we have this class boxer.

115
00:08:48,680 --> 00:08:53,120
So let's actually double tap here in order to make this area wider.

116
00:08:53,300 --> 00:08:57,230
And inside this class I'm going to actually put some lines of code here.

117
00:08:57,380 --> 00:09:00,470
First of all let's actually create some instance variables.

118
00:09:00,500 --> 00:09:08,000
So private and the data type of my variable is going to be strange and the name of my variable is Buxar

119
00:09:08,120 --> 00:09:11,350
name right semicolon.

120
00:09:11,630 --> 00:09:17,630
Let's create another instance variable private integer so that the data type of my variable is integer

121
00:09:17,900 --> 00:09:23,560
and the name is a punch power semicolon.

122
00:09:24,190 --> 00:09:32,780
In int and the name of my instance variable here is Ponch speed semicolon.

123
00:09:32,840 --> 00:09:37,450
So now because you want to actually interact with our firebase database.

124
00:09:37,490 --> 00:09:41,810
First of all you need to actually create an antique constructor.

125
00:09:41,810 --> 00:09:43,210
This is very important.

126
00:09:43,400 --> 00:09:51,560
We must create an empty constructor for our box of class because I want to actually send box objects

127
00:09:51,710 --> 00:09:52,580
to the server.

128
00:09:52,640 --> 00:09:53,180
Right.

129
00:09:53,180 --> 00:09:57,200
So because of that first we need to create an empty constructor.

130
00:09:57,200 --> 00:10:03,200
So here I can say public the access modifier of my constructor is public and the name of the constructor

131
00:10:03,200 --> 00:10:05,910
must be the same as the name of the class.

132
00:10:06,170 --> 00:10:08,830
And then I put a pair of pants here and it here.

133
00:10:08,840 --> 00:10:12,980
I just need to open and close my constructor by using these curly braces.

134
00:10:12,980 --> 00:10:15,190
So this is our empty constructor.

135
00:10:15,830 --> 00:10:23,930
And now we actually should create another constructed in order to initialize our instance variables.

136
00:10:23,930 --> 00:10:30,050
So here again I can't say or I can write it here or I can actually just Right-Click inside this class

137
00:10:30,680 --> 00:10:32,970
and that here actually can generate.

138
00:10:32,990 --> 00:10:36,350
And then he hopefully can constructor.

139
00:10:36,650 --> 00:10:41,570
And now as you can see here we have this instance valuables right box or main punch power and punch

140
00:10:41,570 --> 00:10:42,160
speed.

141
00:10:42,270 --> 00:10:45,710
Just just select all these instance variables.

142
00:10:46,010 --> 00:10:51,160
Just hold the shift key on your keyboard and select all these instance variables and then click on.

143
00:10:51,170 --> 00:10:59,630
OK so now as you can see here are the Android studio Id created this constructor automatically for us

144
00:10:59,750 --> 00:11:00,440
as you can see here.

145
00:11:00,440 --> 00:11:05,480
Now inside it's constructed it is actually initializing these instance variables.

146
00:11:05,570 --> 00:11:08,240
So you are already familiar with these constructors.

147
00:11:08,240 --> 00:11:08,950
Right.

148
00:11:08,960 --> 00:11:13,400
So now we should actually create get Herods for our instance variables.

149
00:11:13,400 --> 00:11:18,470
So as you can see here these instance variables are private instance variables.

150
00:11:18,470 --> 00:11:24,260
So we should create getters are in order to actually get the values in order to actually allow other

151
00:11:24,260 --> 00:11:27,080
classes to get the values of our instance variables.

152
00:11:27,080 --> 00:11:30,560
So here in say this class again I can just right click here.

153
00:11:30,650 --> 00:11:37,520
And then we can generate and then we can get here and then he'll select all these instance variables

154
00:11:37,550 --> 00:11:38,210
and then we can.

155
00:11:38,210 --> 00:11:38,910
OK.

156
00:11:39,080 --> 00:11:45,050
So as you can see here the Android studio ID automatically generated these lines of code for us right.

157
00:11:45,090 --> 00:11:51,800
Kickboxer name pretend box of name get punch power return punch power and get punch speed return punch

158
00:11:51,800 --> 00:11:52,450
speed.

159
00:11:52,580 --> 00:11:55,450
So let's go to our main activity class.

160
00:11:55,840 --> 00:11:58,930
And now inside this class.

161
00:11:58,970 --> 00:12:02,050
First of all let's actually run our project now.

162
00:12:03,430 --> 00:12:07,350
And here we should actually select our virtual device.

163
00:12:07,360 --> 00:12:09,800
So I'm going to select this one and then click on OK.

164
00:12:09,850 --> 00:12:14,370
So now as you can see here our application is running on the emulator.

165
00:12:14,500 --> 00:12:18,210
So here we have free texts or text fields.

166
00:12:18,250 --> 00:12:24,140
We have a button here and we also have a text view inside the scroll view.

167
00:12:24,340 --> 00:12:28,310
So first let's actually create objects for these texts.

168
00:12:28,330 --> 00:12:36,280
So inside this main activity class I'm going to just type in any text and the name of this first text

169
00:12:36,280 --> 00:12:42,040
is going to be EDT box their name.

170
00:12:42,080 --> 00:12:48,800
And now I just need to put a semicolon here or if I want to I can actually declare all these editor

171
00:12:48,810 --> 00:12:53,540
access because these text fields are actually of the same type.

172
00:12:53,650 --> 00:12:56,130
So I can't just declare them in one line of code here.

173
00:12:56,140 --> 00:13:00,810
So here I can see edit text into boxes name karma.

174
00:13:01,120 --> 00:13:04,130
And the second one is EDT punch power.

175
00:13:04,150 --> 00:13:08,920
So here I can say EDT punch power right.

176
00:13:08,950 --> 00:13:13,540
Comma the first one which is actually another edit text or text field.

177
00:13:13,540 --> 00:13:15,450
Here I can say EDT ponse speed.

178
00:13:15,460 --> 00:13:19,380
So here I can see the EDT Ponch speed.

179
00:13:19,750 --> 00:13:25,310
So in this way we are actually declaring three objects of the same type text.

180
00:13:25,360 --> 00:13:26,030
Right.

181
00:13:26,140 --> 00:13:31,900
So if we have an object which is of type it it takes a little box and then we have another object which

182
00:13:31,900 --> 00:13:38,500
is of the text and its name is EDT punch power and we have an other object which is of the text and

183
00:13:38,510 --> 00:13:40,400
an image on speed.

184
00:13:40,420 --> 00:13:40,730
Right.

185
00:13:40,780 --> 00:13:43,970
So here we are declaring free objects of type.

186
00:13:43,990 --> 00:13:44,860
Edit text.

187
00:13:44,980 --> 00:13:45,670
Right.

188
00:13:46,060 --> 00:13:57,040
So now here as you can see we have a button here I can see Button Pythian send data to set for semicolon

189
00:13:57,160 --> 00:14:04,350
and we have actually a few inside are these are inside a vertical scroll view.

190
00:14:04,360 --> 00:14:11,560
So here you can say takes few takes the received data semicolon.

191
00:14:11,800 --> 00:14:16,010
And now let's actually go inside our uncreate Smurfette.

192
00:14:16,160 --> 00:14:22,750
And now let's actually initialize these objects that we created here inside this main activity class.

193
00:14:22,750 --> 00:14:25,940
So first of all this actually initialize this EDT box only.

194
00:14:25,990 --> 00:14:27,140
So it is a boxer name.

195
00:14:27,190 --> 00:14:34,780
Assignment operator is cast this object to it takes object find view by ID or that Id that EDT Boxer

196
00:14:34,780 --> 00:14:36,410
the semicolon.

197
00:14:36,590 --> 00:14:41,570
And now we have EDT punch power assignment operator.

198
00:14:41,650 --> 00:14:45,860
And then I need to recast this object to an edit text object as you can see here.

199
00:14:45,920 --> 00:14:48,670
You want to actually create an object of type every text.

200
00:14:48,670 --> 00:14:49,180
Right.

201
00:14:49,180 --> 00:14:54,290
Because I am referring to a user interface component inside our screen.

202
00:14:54,360 --> 00:14:57,430
You need to have this object to an edit text object.

203
00:14:57,460 --> 00:14:57,950
Right.

204
00:14:58,120 --> 00:15:01,510
So here because I am actually finished with that object.

205
00:15:01,510 --> 00:15:04,520
Are you going to assign that object to the EDT punch power.

206
00:15:04,630 --> 00:15:04,900
Right.

207
00:15:04,900 --> 00:15:09,450
This is actually a variable that holds an object of the text.

208
00:15:09,460 --> 00:15:15,940
So here I can just say find view by ID or thought Id dot EDT.

209
00:15:15,970 --> 00:15:21,350
Punch power semicolon and the next one is this one ADT upon speed.

210
00:15:21,370 --> 00:15:23,860
So it it up on speed.

211
00:15:23,860 --> 00:15:30,700
Assignment operator and here I need to cast this object to an edit text object find view by ID or that

212
00:15:30,760 --> 00:15:37,780
Id dot EDT Ponch speed and then I need to put a semicolon at the end of my statement and the next one

213
00:15:37,790 --> 00:15:40,180
is disputing Pythian send data to server.

214
00:15:40,180 --> 00:15:45,910
So here I can't say BT and send data to a server assignment operator and then I need to test this object

215
00:15:45,910 --> 00:15:54,610
to a button object as you can see here find view by the are that Id dot PTEN send data semi-colon and

216
00:15:54,610 --> 00:15:57,690
the next one is this text view object.

217
00:15:57,740 --> 00:15:59,470
It takes you a valuable actually.

218
00:15:59,590 --> 00:16:03,520
So here you need to actually create an object that takes you.

219
00:16:03,520 --> 00:16:07,830
So here I can see TXI the received data assignment operator.

220
00:16:07,990 --> 00:16:15,540
And here I need to cast this object to our text view object find view by ID or thought Id dot takes

221
00:16:15,760 --> 00:16:18,660
the received data semicolon.

