1
00:00:00,150 --> 00:00:08,070
High students in this Tauriel I want to talk about a l Android interface language definition.

2
00:00:08,340 --> 00:00:16,440
So now let's create a new Android studio project and for the application name just hit app 1:53 dash

3
00:00:16,750 --> 00:00:18,390
a.

4
00:00:18,990 --> 00:00:24,870
So you can specify the company domain package name and the project location and then click on next and

5
00:00:24,870 --> 00:00:30,000
here choose a 16 Android 4.1 jelly bean and it connects.

6
00:00:30,360 --> 00:00:32,850
And here too is empty activity next.

7
00:00:33,120 --> 00:00:36,220
And here you don't have to change anything.

8
00:00:36,270 --> 00:00:37,720
And then click on finish.

9
00:00:37,740 --> 00:00:45,000
So now that our project is actually created Let's go to let's first design the user interface of our

10
00:00:45,000 --> 00:00:51,300
application so called Inside this race that lay out and then double double click on this activity underline

11
00:00:51,460 --> 00:00:52,290
that example.

12
00:00:52,530 --> 00:01:01,080
So here let's delete this hello world takes you here and now let's actually tried to a text field inside

13
00:01:01,160 --> 00:01:02,390
this layout.

14
00:01:02,430 --> 00:01:09,480
So at the bottom first click click on this text tab and change this relatively out to linearly out.

15
00:01:09,750 --> 00:01:15,210
And now let's specify the orientation of this layout orientation vertical.

16
00:01:15,210 --> 00:01:16,670
So let's go to design tap.

17
00:01:16,850 --> 00:01:19,110
And now let's drag two text fields.

18
00:01:19,110 --> 00:01:22,210
So it's 36 minutes for the just selected number.

19
00:01:22,230 --> 00:01:22,600
Right.

20
00:01:22,620 --> 00:01:23,470
Right.

21
00:01:23,470 --> 00:01:27,310
Select this one and just drag it into this linearly arithmetic.

22
00:01:27,630 --> 00:01:29,680
Let's actually try another text with.

23
00:01:29,700 --> 00:01:33,080
So again select this number and just track it here.

24
00:01:33,420 --> 00:01:36,470
So now we have to edit this here right to takes fields.

25
00:01:36,690 --> 00:01:41,930
So just select this one the first one and let's specify the ID sort for the ID just type in here it

26
00:01:41,930 --> 00:01:50,610
is the first number and the person tells you on your keyboard and for the set this second detects you

27
00:01:50,650 --> 00:01:53,130
are selected and for the idea just type in here.

28
00:01:53,130 --> 00:01:53,850
EDT.

29
00:01:53,850 --> 00:01:59,100
Second number right and that person enter key on your keyboard.

30
00:01:59,400 --> 00:02:04,920
So now let's actually track a button into these lay out.

31
00:02:04,920 --> 00:02:06,610
So inside this we just fall there.

32
00:02:06,690 --> 00:02:07,760
Select the spot.

33
00:02:07,920 --> 00:02:10,370
And just like it here and put it here below.

34
00:02:10,430 --> 00:02:19,360
It takes here and just select this button and for the idea of say in here Betty Betty and multiply Pythian

35
00:02:19,410 --> 00:02:26,420
multiply and then person until you are on your keyboard and for the text to say in here let's select

36
00:02:26,420 --> 00:02:34,620
the text attribute and just type in here or multiply multiply and that person an interview on your keyboard.

37
00:02:35,000 --> 00:02:39,640
So now let's actually just write a text view.

38
00:02:39,750 --> 00:02:46,630
So just select it takes you here and put it here below the Spartan and select takes.

39
00:02:46,670 --> 00:02:57,380
And for the idea to step in here takes the multiply result takes the multiply result and then person

40
00:02:57,410 --> 00:03:03,770
enter on your keyboard and just delete this value for the text attribute of this text.

41
00:03:04,130 --> 00:03:08,050
So now are we actually designed the user interface or application.

42
00:03:08,060 --> 00:03:11,160
So now I want to talk about a idea.

43
00:03:11,330 --> 00:03:14,830
So first let's see how we can actually create a idealy an android.

44
00:03:14,990 --> 00:03:19,140
So just select this app folder there so make sure that you are inside the Android view.

45
00:03:19,190 --> 00:03:19,730
Right.

46
00:03:19,790 --> 00:03:26,390
So if you just click on these two little triangles here make sure that you have selected Android and

47
00:03:26,390 --> 00:03:33,920
select this app folder at the top click on find new and in just here you can see this idea right.

48
00:03:33,920 --> 00:03:40,490
So just click on a IDL file and here you can actually specify the interface name.

49
00:03:40,550 --> 00:03:48,790
So for the interface name we can say for example here the default name is my up are it a the interface.

50
00:03:48,800 --> 00:03:49,880
I think it's good.

51
00:03:49,880 --> 00:03:57,110
This is actually an interface and other classes can implement this interface can't conform to this interface

52
00:03:57,440 --> 00:04:02,260
so that they can actually use the functionalities of this interface.

53
00:04:02,450 --> 00:04:04,050
So let's just name it.

54
00:04:04,340 --> 00:04:12,230
Multiply multiply interface aren't the target source is me.

55
00:04:12,310 --> 00:04:14,560
So just click on finish.

56
00:04:14,700 --> 00:04:20,820
So now as you can see inside this app folder we have another folder called IDL.

57
00:04:20,940 --> 00:04:24,060
And inside this folder we have our package right.

58
00:04:24,060 --> 00:04:29,770
And inside this package we have this wide multiplayer interface that IDL.

59
00:04:29,930 --> 00:04:36,150
So look at this comment here it says demonstrates some basic types that you can use as parameters and

60
00:04:36,150 --> 00:04:39,050
return values in IDL right.

61
00:04:39,360 --> 00:04:43,800
So here you can see these totals as you can see it's essentially a Meffert basic types.

62
00:04:43,800 --> 00:04:48,460
These are the types in integer Lanc boolean float double and string.

63
00:04:48,660 --> 00:04:52,130
So let's actually delete this comment and this method here.

64
00:04:52,230 --> 00:04:58,970
So here as you can see we have an interface right interface multiplayer interface right.

65
00:04:59,040 --> 00:05:07,380
So let me tell you that the end is used for actually creating a relationship between the client and

66
00:05:07,380 --> 00:05:08,850
the remote server.

67
00:05:08,850 --> 00:05:09,310
Right.

68
00:05:09,330 --> 00:05:15,570
So for example the main activity is the client and the server is going to be of the class that is actually

69
00:05:15,570 --> 00:05:17,790
playing the role of a server service.

70
00:05:17,790 --> 00:05:21,920
Let me show you an example here and then it will completely make sense right.

71
00:05:22,050 --> 00:05:29,340
By showing you by creating a real application you cannot actually understand what is ideal used for.

72
00:05:29,340 --> 00:05:34,770
So now inside this interface inside the curly braces of this interface let's write some code.

73
00:05:34,950 --> 00:05:41,610
So now as the name of our interface suggests this is going to be an interface for multiplying values.

74
00:05:41,610 --> 00:05:42,170
Right.

75
00:05:42,390 --> 00:05:49,820
So here I am going to declare a method for that is anybody going to use for multiplying values.

76
00:05:49,830 --> 00:05:52,350
So here I can see it.

77
00:05:52,410 --> 00:05:55,530
So this is going to be the return type of of my method right.

78
00:05:55,680 --> 00:06:08,160
And here I can say multiply multiply two values two values together and then here I can just put a pair

79
00:06:08,160 --> 00:06:13,160
of parenthesis so this method is going to accept some parameters to make parameters actually.

80
00:06:13,170 --> 00:06:16,060
So the first parameter is going to be of type integer.

81
00:06:16,060 --> 00:06:21,440
So int and here I can say first number comma.

82
00:06:21,860 --> 00:06:30,020
And so this is going to be the second parameter second number and because this is actually an interface

83
00:06:30,290 --> 00:06:36,740
and you are already familiar with interfaces in Java you cannot provide a body for this method.

84
00:06:36,740 --> 00:06:39,170
This is going to be a declaration of this method.

85
00:06:39,200 --> 00:06:45,080
So if you just need to put a semicolon at the end at the end of our statement here right we just declared

86
00:06:45,140 --> 00:06:49,330
this method we do not provide implementation here inside this interface.

87
00:06:49,350 --> 00:06:56,350
So now let's actually create a service so at the top just click on file first.

88
00:06:56,480 --> 00:06:58,120
Let's go to view here.

89
00:06:58,130 --> 00:07:03,380
So at the top just click on a view and then open windows and then click on Project.

90
00:07:03,380 --> 00:07:04,120
Right.

91
00:07:04,340 --> 00:07:12,020
And now we want to actually create a service that implements this interface that implements this IDL

92
00:07:12,020 --> 00:07:15,220
here and then we can actually use that service.

93
00:07:15,320 --> 00:07:21,350
So let's actually select this top a failure here just open it and then select this package and at the

94
00:07:21,350 --> 00:07:26,740
top just click on find new and then click on the service to select a service here.

95
00:07:26,750 --> 00:07:28,130
So this is the service right.

96
00:07:28,130 --> 00:07:29,810
And then here we have two options.

97
00:07:29,810 --> 00:07:33,350
Service and the second one is service intent service.

98
00:07:33,500 --> 00:07:37,690
So select this one service here and for the class name.

99
00:07:37,780 --> 00:07:38,950
This is going to be a class.

100
00:07:38,960 --> 00:07:39,600
Right.

101
00:07:39,620 --> 00:07:46,340
So here I can say multiplication multi placation series.

102
00:07:46,640 --> 00:07:48,930
So this is the name on what the name of my service.

103
00:07:48,950 --> 00:07:49,410
Right.

104
00:07:49,640 --> 00:07:51,260
And then click can finish.

105
00:07:51,770 --> 00:07:56,950
So now we have a new class and the name of this class is multiplication service.

106
00:07:56,960 --> 00:07:57,590
Right.

107
00:07:57,890 --> 00:08:04,070
So you can see that this is a public class and this class extends the service class.

108
00:08:04,070 --> 00:08:10,640
So in the inside this class we have this empty constructor that is actually already provided for us

109
00:08:10,880 --> 00:08:11,880
by Android.

110
00:08:12,290 --> 00:08:14,930
And we have this method that is overrated here.

111
00:08:14,930 --> 00:08:21,050
And as you can see some of this if it is actually an bind that returns a value of type A binder.

112
00:08:21,140 --> 00:08:21,710
Right.

113
00:08:22,040 --> 00:08:24,190
So now let's see how we can use the Smiff.

114
00:08:24,200 --> 00:08:25,120
So look at this comment.

115
00:08:25,120 --> 00:08:29,700
It says Return the communication channel to the service.

116
00:08:29,780 --> 00:08:30,340
Right.

117
00:08:30,470 --> 00:08:34,720
So now let's just double click on this tab here.

118
00:08:34,850 --> 00:08:36,230
This multiplication.

119
00:08:36,230 --> 00:08:38,690
So we start over top in order to make this area there.

120
00:08:38,870 --> 00:08:45,200
First let's actually delete these two lines of code here and now I mean I dismiss it right.

121
00:08:45,200 --> 00:08:49,380
First of all Vin Weber that you actually create an ideal file.

122
00:08:49,530 --> 00:08:54,090
So now let me show you that file here view tool windows and then project.

123
00:08:54,110 --> 00:09:00,860
So inside our project we have this idea file right with the extension dot a IDL white men over it that

124
00:09:00,860 --> 00:09:05,480
you create a file that is actually has the extension a IDL.

125
00:09:05,630 --> 00:09:09,070
You must actually build your project.

126
00:09:09,200 --> 00:09:12,560
So at the top click on build and here you have two options.

127
00:09:12,560 --> 00:09:14,670
Clean project and rebuild project.

128
00:09:14,690 --> 00:09:18,890
So when you choose the rebuild project it's going to first clean your project and then it's going to

129
00:09:18,890 --> 00:09:19,800
build your project.

130
00:09:19,910 --> 00:09:22,000
So it's better to choose this option.

131
00:09:22,010 --> 00:09:23,030
Rebuild the project.

132
00:09:23,090 --> 00:09:24,290
So just elected.

133
00:09:24,650 --> 00:09:28,030
And as you can see at the bottom it says great deal be threatening.

134
00:09:28,040 --> 00:09:29,880
So let's wait a little bit here.

135
00:09:31,280 --> 00:09:34,030
So now as you can see it's actually running.

136
00:09:34,070 --> 00:09:35,740
So now everything is OK.

137
00:09:35,840 --> 00:09:36,410
Right.

138
00:09:36,680 --> 00:09:39,350
And now my project is to rebuild.

139
00:09:39,470 --> 00:09:42,230
So now let's go inside this method on buying it.

140
00:09:42,270 --> 00:09:45,370
Look at the return type of the Smurfette I'd buy in there.

141
00:09:45,500 --> 00:09:48,550
So here we must through of value of paper.

142
00:09:48,560 --> 00:09:49,530
Are you buying that right.

143
00:09:49,610 --> 00:09:52,190
So here first let's put this statement here.

144
00:09:52,220 --> 00:10:03,710
So just step in here return return my binder semicolon return my binder.

145
00:10:04,280 --> 00:10:06,610
So this is going to be the return value.

146
00:10:06,620 --> 00:10:12,090
But as you can see we have an error and this means that we haven't created this return value.

147
00:10:12,110 --> 00:10:18,080
So now let's actually tap to just publicly tap here in order to make this area wider.

148
00:10:18,440 --> 00:10:23,820
And let's go inside the curly braces of this clap class multiplication.

149
00:10:23,860 --> 00:10:24,190
Right.

150
00:10:24,200 --> 00:10:29,600
So after the end in calibrates of this Meffert unbind and before the end in Crilley place of this class.

151
00:10:29,600 --> 00:10:32,780
So inside this class just typing here.

152
00:10:32,810 --> 00:10:40,800
So the name of our IDL file is actually multiply multiply interface.

153
00:10:40,820 --> 00:10:45,170
So here we want to create an object of type A binder right.

154
00:10:45,170 --> 00:10:51,960
So in order to do that first we first read the name of your ID or find multiplayer interface dot stop.

155
00:10:51,980 --> 00:10:53,580
This is really important stuff.

156
00:10:53,580 --> 00:10:59,740
With capital S and now we can actually name of name or update we can give a name to our object.

157
00:10:59,870 --> 00:11:01,550
So the name is going to be this name right.

158
00:11:01,560 --> 00:11:02,400
My binder.

159
00:11:02,450 --> 00:11:07,820
So here I can say my binder assignment operator.

160
00:11:07,940 --> 00:11:09,700
So now let's create an object.

161
00:11:09,700 --> 00:11:15,130
So here you're actually just creating a variable of type multiplayer interface that stop.

162
00:11:15,260 --> 00:11:15,890
Right.

163
00:11:15,890 --> 00:11:18,420
So now let's create the actual object.

164
00:11:18,420 --> 00:11:23,430
So in order to do that first you need to put the new vote and then you just you just need to put.

165
00:11:23,540 --> 00:11:28,760
You just need to refer to your interface to your ideal file multiplayer interface.

166
00:11:28,880 --> 00:11:35,300
So when you put the capital in here it's actually the auto companies feature of Android studio is going

167
00:11:35,300 --> 00:11:37,340
to help you to choose this option.

168
00:11:37,370 --> 00:11:38,200
Stop right.

169
00:11:38,210 --> 00:11:39,220
Start with chapiter.

170
00:11:39,260 --> 00:11:42,450
And inside the curly braces you can see these dot dot dot.

171
00:11:42,590 --> 00:11:44,610
So select this one and then press not.

172
00:11:44,830 --> 00:11:45,660
On your keyboard.

173
00:11:45,860 --> 00:11:52,630
So now the autocomplete feature of Android would you put these lines of code here for you automatically.

174
00:11:52,640 --> 00:11:57,110
So here we have an error and after the end curly brace here just put a semicolon.

175
00:11:57,140 --> 00:11:58,700
So now the error is gone.

176
00:11:58,700 --> 00:12:03,090
So now here let's create a new line so that you can assume it can actually the whole method here.

177
00:12:03,140 --> 00:12:05,320
You can see the whole method here.

178
00:12:05,330 --> 00:12:08,570
So now we have actually the over write it up.

179
00:12:08,600 --> 00:12:14,840
We have we have a new order right at Mefford and the access modifier of this method is probably the

180
00:12:14,840 --> 00:12:21,890
return type of this if it is integer and the name of the Smurfit is multiply two values together.

181
00:12:21,890 --> 00:12:23,780
So as you can see we have actually a typo.

182
00:12:23,810 --> 00:12:30,650
Let's go to our multiply interface that IDL So as you can see I did I did a mistake and instead of you

183
00:12:30,650 --> 00:12:31,480
I put y.

184
00:12:31,490 --> 00:12:36,560
So let's just delete this Y and put you multiply two values to get that.

185
00:12:36,560 --> 00:12:40,040
So let's go to our series multiplication service.

186
00:12:40,280 --> 00:12:42,670
And now let's actually change this one to you.

187
00:12:42,920 --> 00:12:50,390
So because we actually changed our ID file again we must just build our project so at the tactical we

188
00:12:50,390 --> 00:12:53,570
can build and then selectively build project.

189
00:12:53,570 --> 00:12:58,340
So let's wait a little bit here and now everything is fine.

190
00:12:58,490 --> 00:12:58,850
Right.

191
00:12:58,850 --> 00:13:00,430
We have no errors here.

192
00:13:00,500 --> 00:13:01,730
So here we have this method.

193
00:13:01,730 --> 00:13:05,970
Multiply two values together and this Smif it accepts two arguments.

194
00:13:06,080 --> 00:13:10,450
The first one is that integer first number and the second one is of type integer second number.

195
00:13:10,460 --> 00:13:11,270
Right.

196
00:13:11,390 --> 00:13:14,980
So now as you can see this MF'er the froze an exception.

197
00:13:14,990 --> 00:13:20,750
So if you want to actually use the Smurfette then our main activity want to use the Smurfette we must

198
00:13:20,750 --> 00:13:22,530
actually handle this exception.

199
00:13:22,730 --> 00:13:26,250
So this Meffert by default returns a value of type integer which is zero.

200
00:13:26,330 --> 00:13:28,230
So we don't want this statement here.

201
00:13:28,250 --> 00:13:29,200
Just delete it.

202
00:13:29,360 --> 00:13:34,500
And now as its name suggests multiply two values together and say return.

203
00:13:34,910 --> 00:13:37,920
So now we have this Meffert accepts two prime hitters right.

204
00:13:38,030 --> 00:13:46,110
So I the first the name of this first number first number multiplied by second number.

205
00:13:46,130 --> 00:13:52,080
So now you can see that this service is actually implemented in this interface.

206
00:13:52,080 --> 00:13:54,720
This multiplayer interface that IDL.

207
00:13:54,740 --> 00:13:55,350
Right.

208
00:13:55,370 --> 00:13:58,080
So we created an ideal file here.

209
00:13:58,100 --> 00:14:03,350
And as you can see this is actually just a simple interface right and you are already familiar with

210
00:14:03,350 --> 00:14:04,960
interfaces in Java.

211
00:14:05,240 --> 00:14:11,480
And we created a service which is this one multiplication service and this service is actually implementing

212
00:14:11,630 --> 00:14:18,840
this interface so that we can actually provide an implementation for them for them if at this interface.

213
00:14:19,070 --> 00:14:26,300
So now we have this Meffert here and this certainly as you can see we have actually an over Meffert

214
00:14:26,540 --> 00:14:30,560
and this service needs to return a value of five and a binder right.

215
00:14:30,580 --> 00:14:33,560
So if we just returned this my binder here.

216
00:14:33,650 --> 00:14:36,140
So now let's go to our main activity here.

217
00:14:36,140 --> 00:14:38,510
So this is going to be our client.

218
00:14:38,630 --> 00:14:39,400
Right.

219
00:14:39,470 --> 00:14:45,180
So now we can actually just interact with the remote service.

220
00:14:45,350 --> 00:14:46,100
Right.

221
00:14:46,100 --> 00:14:51,440
So if you have actually an interface and we have a service and we have a client which is the main activity

222
00:14:51,890 --> 00:14:58,430
and the main activity can interact with the remote service by this idea find this multiply into an interface

223
00:14:58,430 --> 00:14:59,620
that idea.

224
00:14:59,860 --> 00:15:08,540
So that's the whole concept of a deal in Android right Android interface language definition.

225
00:15:08,630 --> 00:15:09,090
Right.

226
00:15:09,150 --> 00:15:13,100
A d l and that's the whole concept.

227
00:15:13,310 --> 00:15:15,660
And now you can actually figure out what's going on here.

228
00:15:15,830 --> 00:15:19,670
So let's go to our main activity and let's see how we can use this service.

229
00:15:19,670 --> 00:15:25,550
So first of all let's actually just declared this the objects the user interface components that we

230
00:15:25,550 --> 00:15:26,260
put here.

231
00:15:26,420 --> 00:15:30,580
So we have to edit takes we have a patent and we have a text view.

232
00:15:30,710 --> 00:15:34,710
So let's go to main activity and say this class here.

233
00:15:35,060 --> 00:15:37,170
First I can't say that it works.

234
00:15:37,430 --> 00:15:44,570
So here I can say it is your first number the first number so I can actually declare my two objects

235
00:15:44,750 --> 00:15:45,350
which are of type.

236
00:15:45,360 --> 00:15:46,600
It takes in just one line.

237
00:15:46,640 --> 00:15:51,560
So comma it is the second number.

238
00:15:51,650 --> 00:15:52,990
Right semicolon.

239
00:15:53,210 --> 00:15:57,670
And then if you have actually a patent spot in between.

240
00:15:57,790 --> 00:15:58,440
Multiply

241
00:16:00,950 --> 00:16:06,120
semi-colon and we have a Takes view so it takes you to 60.

242
00:16:06,320 --> 00:16:12,800
Multiply multiply result takes the multiply result semicolon.

243
00:16:12,980 --> 00:16:16,280
So now let's go inside the Smurfette uncreate right.

244
00:16:16,460 --> 00:16:21,070
And now let's initialize these Optix that we actually declared inside our class.

245
00:16:21,080 --> 00:16:25,940
So the first one is a little first number assignment operator and then we need to cast this object on

246
00:16:25,970 --> 00:16:32,500
any text object find view by ID or that Id dot EDT first number semicolon.

247
00:16:32,850 --> 00:16:40,710
Is the second number assignment operator let's cast this object to an end it takes up to act fine.

248
00:16:40,780 --> 00:16:44,910
View by ID or data ID that EDT.

249
00:16:45,080 --> 00:16:47,110
Second number semicolon.

250
00:16:47,630 --> 00:16:52,580
And we have this button in between and multiply so between multiply assignment operator let's cast this

251
00:16:52,610 --> 00:17:00,680
object to our button object find view by ID or that Id that PTEN multiply semi-colon and we have THC

252
00:17:00,680 --> 00:17:01,980
multiplier is that.

253
00:17:02,040 --> 00:17:04,630
So the multiplier is an assignment operator.

254
00:17:04,650 --> 00:17:11,710
There's that cestus object to our text view object find view Id or ID that he likes the multiply.

255
00:17:11,710 --> 00:17:13,460
Who is that right.

256
00:17:13,490 --> 00:17:16,310
So not everything is fine everything is OK.

257
00:17:16,520 --> 00:17:20,560
So now let's see how we can use this service.

258
00:17:20,570 --> 00:17:24,950
So first of all let's create our listener for the spot in the city and multiply.

259
00:17:24,950 --> 00:17:29,470
So whenever the user clicks on the spot in this button something is going to happen.

260
00:17:29,480 --> 00:17:33,710
So here I'm going to actually implement the view that unclick listener interface.

261
00:17:33,710 --> 00:17:43,010
So class main activity extends app compact activity implements you dot unclick listener.

262
00:17:43,040 --> 00:17:45,530
So now here inside is uncreate Smurfette.

263
00:17:45,550 --> 00:17:50,370
Here I can say PTEN or multiply that set unclick listener.

264
00:17:50,630 --> 00:17:56,150
And then here I need to pass the context so the context is an activity that this and then here inside

265
00:17:56,180 --> 00:18:01,930
the class inside this main activity class we must actually provide an implementation for the uncleaned

266
00:18:01,930 --> 00:18:02,510
method.

267
00:18:02,780 --> 00:18:05,990
That is that is inside of this view that unclick listener interface.

268
00:18:05,990 --> 00:18:14,300
So inside this class I can just see unclick and here and click and now the autocomplete feature of Android

269
00:18:14,300 --> 00:18:18,360
studio is helping me to use this method and then person enter on your keyboard.

270
00:18:18,560 --> 00:18:21,630
So now we have the Smurfette here inside this class.

271
00:18:21,710 --> 00:18:25,280
So let's go to our uncreate Smurfette.

272
00:18:25,610 --> 00:18:30,280
And here we have actually a method called Blind service.

273
00:18:30,320 --> 00:18:37,790
So now we may want to ask ourselves what we want to do here if we want to bind this our main activity

274
00:18:37,790 --> 00:18:40,990
this client of this service.

275
00:18:41,090 --> 00:18:43,530
So we want to use this method bind service.

276
00:18:43,550 --> 00:18:44,050
Right.

277
00:18:44,240 --> 00:18:48,890
So let me show you what are the arguments of this method.

278
00:18:48,920 --> 00:18:52,350
The first argument is going to be of type service right.

279
00:18:52,370 --> 00:18:57,220
And as you can see the first one is actually of that intent and the name is service.

280
00:18:57,230 --> 00:18:59,030
So we need to pass the Internet.

281
00:18:59,030 --> 00:19:05,030
And the second argument is this service connection and the third argument is actually Flack's which

282
00:19:05,030 --> 00:19:06,420
is I-5 integer.

283
00:19:06,500 --> 00:19:11,290
So we need to pass these arguments through the Smurfette so that we can use this method.

284
00:19:11,660 --> 00:19:13,100
So let's see how we can do that first.

285
00:19:13,130 --> 00:19:14,340
Let's actually create.

286
00:19:14,550 --> 00:19:16,150
The intent as you can see here.

287
00:19:16,210 --> 00:19:23,360
So before the declaration before use the people calling this method bind service we need to actually

288
00:19:23,360 --> 00:19:24,570
create the intent.

289
00:19:24,710 --> 00:19:26,550
So let's do that here.

290
00:19:26,570 --> 00:19:29,560
So here I can't say intent intent

291
00:19:32,340 --> 00:19:32,880
right.

292
00:19:32,940 --> 00:19:35,640
And that name is going to be months play intense multi

293
00:19:38,640 --> 00:19:42,490
multiply intent assignment operator.

294
00:19:43,110 --> 00:19:49,430
And then when you say we are just creating of value but of intent and the name is multiply intent.

295
00:19:49,560 --> 00:19:52,890
So now we want to create the actual object of intent.

296
00:19:52,890 --> 00:19:53,380
Right.

297
00:19:53,400 --> 00:19:55,200
So here I just put new.

298
00:19:55,470 --> 00:20:02,790
And then I can just say intent and this method should add that the constructor of intent needs two arguments.

299
00:20:02,790 --> 00:20:04,410
First we need to pass the context.

300
00:20:04,410 --> 00:20:11,630
So here I can say main activity that this comma and the second argument is going to be service right.

301
00:20:11,850 --> 00:20:17,820
So if we actually hover over this bind so we see it it says the first argument is actually off that

302
00:20:17,840 --> 00:20:19,660
intent but the name is service.

303
00:20:19,680 --> 00:20:23,120
So we already created this multiplication so we see it right.

304
00:20:23,130 --> 00:20:29,060
So for the second argument I can pass this multiplication service here so I can say multiplication.

305
00:20:29,070 --> 00:20:31,980
So we start a class semicolon.

306
00:20:32,190 --> 00:20:32,730
Right.

307
00:20:32,940 --> 00:20:39,650
So now you know that YV actually create a disservice because we want to bind this may not be with this

308
00:20:39,690 --> 00:20:42,290
client we deserve service right.

309
00:20:42,340 --> 00:20:45,240
And now if we pass this multiplication said was here.

310
00:20:45,390 --> 00:20:48,760
So now we have the first argument multiplied into.

311
00:20:48,780 --> 00:20:55,170
So here I can say multiply intent karma or I can say multiply servies.

312
00:20:55,170 --> 00:20:58,640
It's better to actually put multiply so.

313
00:20:58,650 --> 00:21:05,120
It's more meaningful multiply series.

314
00:21:05,210 --> 00:21:08,660
So let's change this one two months to play service.

315
00:21:08,680 --> 00:21:11,980
So now we need to specify the second argument.

316
00:21:12,040 --> 00:21:15,110
So the second argument is actually a service connection.

317
00:21:15,160 --> 00:21:15,540
Right.

318
00:21:15,670 --> 00:21:20,360
So let's actually create an object of types that service action inside is main activity class.

319
00:21:20,410 --> 00:21:25,600
So after the end curly brace of the Smurfit uncreate an insight is main activity class.

320
00:21:25,610 --> 00:21:29,570
I'm going to create actually an object of service connection here.

321
00:21:29,680 --> 00:21:38,920
So here I can say service connection service connection and the name is going to be my service connection

322
00:21:38,980 --> 00:21:42,390
my service connection.

323
00:21:42,820 --> 00:21:47,330
And then I put an assignment operator here and I put the new keyboard.

324
00:21:48,000 --> 00:21:50,580
And here I want to use it.

325
00:21:50,640 --> 00:21:53,250
I actually want to create an anonymous in a class.

326
00:21:53,260 --> 00:21:57,030
So let me tell you that this service connection is not a class.

327
00:21:57,160 --> 00:21:58,610
This is just an interface.

328
00:21:58,630 --> 00:22:04,070
So let's let me just hold the combination on a keyboard and then click on the service connection here.

329
00:22:04,270 --> 00:22:06,210
As you can see this is not a class.

330
00:22:06,280 --> 00:22:11,570
This is an interface here with this if it's on service connected and answer was disconnected.

331
00:22:11,620 --> 00:22:12,580
Right.

332
00:22:12,630 --> 00:22:15,280
So you want to actually use this interface.

333
00:22:15,290 --> 00:22:23,080
So now here I am going to create an anonymous class that actually conforms to this interface that implements

334
00:22:23,080 --> 00:22:24,150
this interface.

335
00:22:24,160 --> 00:22:30,370
So here I can see new and then I hold the shift key on my keyboard and then I actually present them

336
00:22:30,520 --> 00:22:32,100
as key on my keyboard.

337
00:22:32,110 --> 00:22:38,140
So now it's you can see that the autocomplete of the autocomplete feature of Android studio is helping

338
00:22:38,140 --> 00:22:39,400
me to choose this option.

339
00:22:39,400 --> 00:22:44,320
So misconnection right as you can see you can see these curly braces such as this one and they press

340
00:22:44,320 --> 00:22:45,760
that intellectual keyboard.

341
00:22:46,090 --> 00:22:52,300
So now you can see that the Android studio provided these quotes here for me automatically.

342
00:22:52,330 --> 00:22:57,610
So now we need to put a semicolon at the end of this or calibers year after the ending calibers and

343
00:22:57,610 --> 00:22:59,260
now everything is fine.

344
00:22:59,530 --> 00:23:05,830
So if you have the anonymous in a class that conforms or implements this service connection and if you

345
00:23:05,830 --> 00:23:10,930
have this tumor if it's you're over rated for us we must actually provide an implementation for these

346
00:23:10,930 --> 00:23:13,620
methods because this is an interface.

347
00:23:13,660 --> 00:23:16,260
So now inside this on we can act.

348
00:23:16,290 --> 00:23:18,700
So we want to use the Smurfit on service connected.

349
00:23:18,760 --> 00:23:19,340
Right.

350
00:23:19,600 --> 00:23:21,810
So we need to put a logic.

351
00:23:21,820 --> 00:23:29,150
So now first of all let's create a valuable of type multiplayer interface inside our class.

352
00:23:29,170 --> 00:23:32,820
So let's actually scroll to the top and inside is main activity class here.

353
00:23:33,010 --> 00:23:36,140
I can just create a variable of multiplayer interface.

354
00:23:36,250 --> 00:23:38,660
So here I can say multiply interface.

355
00:23:38,680 --> 00:23:44,960
Let's actually keep this valuable name right so that the data type is multiplayer interface.

356
00:23:45,010 --> 00:23:51,210
And here I can say my interface right my interface semi-colon.

357
00:23:51,520 --> 00:23:53,880
So now let's actually scroll down here.

358
00:23:53,890 --> 00:23:56,660
So here we just declare this valuable right.

359
00:23:56,680 --> 00:23:57,670
My interface.

360
00:23:57,700 --> 00:24:01,730
Now let's scroll down here and let's go inside this on it connected.

361
00:24:02,050 --> 00:24:04,320
And now let's initialize disparity table.

362
00:24:04,340 --> 00:24:07,990
So here I can see my interface assignment operator.

363
00:24:08,020 --> 00:24:10,500
So look at the Smurfette here on service connected.

364
00:24:10,600 --> 00:24:12,910
This it accepts two parameters.

365
00:24:13,000 --> 00:24:17,470
The first one is component's name and the second one is a binder.

366
00:24:17,470 --> 00:24:24,790
So if you want to use this binder here because we want to actually bind this client main activity with

367
00:24:24,790 --> 00:24:27,580
the interface right with this service.

368
00:24:27,580 --> 00:24:30,680
So now let's actually just type in here.

369
00:24:30,820 --> 00:24:37,180
Monte playlets actually refer to the name of this interface multiply interface that ADL.

370
00:24:37,180 --> 00:24:45,970
So here I can say multiplayer interface multiplayer interface that stop here and that here I can say

371
00:24:46,080 --> 00:24:52,560
that as interface and design if it actually needs an argument of type I bind.

372
00:24:52,570 --> 00:24:57,010
So we actually get this a binder from the Smurfit from this on said Can I get my fit.

373
00:24:57,010 --> 00:25:00,020
So here we can pass this binder to the smith.

374
00:25:00,130 --> 00:25:02,950
So here I can say a binder semi-colon.

375
00:25:02,950 --> 00:25:10,000
So by using the service connection we are actually connecting these Servius this multiplication service

376
00:25:10,210 --> 00:25:11,440
to this interface.

377
00:25:11,470 --> 00:25:14,880
We have the second argument of this point service Smurfit.

378
00:25:15,010 --> 00:25:17,940
So the second argument is my service connection.

379
00:25:17,950 --> 00:25:19,490
So we created this one here.

380
00:25:19,600 --> 00:25:20,060
Right.

381
00:25:20,290 --> 00:25:23,670
And we actually provided the first argument.

382
00:25:23,980 --> 00:25:28,860
So the first argument is of type integer and it is actually a flag.

383
00:25:29,080 --> 00:25:33,970
So here I can say so now as you can see I actually saw it.

384
00:25:34,030 --> 00:25:36,720
I mistakenly deleted the name of this value.

385
00:25:36,750 --> 00:25:39,700
So let me actually undo this action.

386
00:25:39,880 --> 00:25:45,480
So I put a name here so now we have my cell connection right so I can put the comma here.

387
00:25:45,700 --> 00:25:48,780
And now you need to specify the first argument.

388
00:25:48,910 --> 00:25:49,420
Right.

389
00:25:49,600 --> 00:25:54,320
And now that the argument is of type integers so it is actually going to be context.

390
00:25:54,430 --> 00:25:56,150
So this is going to be a flag.

391
00:25:56,260 --> 00:25:57,890
So we must put the flag here.

392
00:25:58,000 --> 00:26:07,030
So here I can say context dot and here we actually choose this one bind auto create write bind all to

393
00:26:07,030 --> 00:26:07,590
create.

394
00:26:07,600 --> 00:26:10,100
This is really important this is the flag that we use.

395
00:26:10,210 --> 00:26:13,970
So its going to bind this service with that interface.

396
00:26:14,620 --> 00:26:17,420
So just put a semicolon at the end of your statement.

397
00:26:17,560 --> 00:26:18,640
Right.

398
00:26:18,640 --> 00:26:22,350
So now we have this spine was here for us.

399
00:26:22,420 --> 00:26:27,060
So its going to do the job for us and we pass these arguments multiply service.

400
00:26:27,070 --> 00:26:28,210
So this is the intent.

401
00:26:28,540 --> 00:26:35,410
And then we have the service connection and then actually the past display context that bind auto create.

402
00:26:35,410 --> 00:26:39,130
So now the binding is actually implemented here.

403
00:26:39,340 --> 00:26:42,720
So let's go to these uncreate method here.

404
00:26:42,720 --> 00:26:47,340
So first of all let's actually just as you can see we have these Eadie takes here.

405
00:26:47,340 --> 00:26:47,700
Right.

406
00:26:47,820 --> 00:26:52,950
So if you want to get the value of this as it takes and this one and then if you want to multiply these

407
00:26:52,950 --> 00:26:53,810
two values together.

408
00:26:53,850 --> 00:27:00,030
And then when the user clicks on this button the result is going to be shown here on this TXI the multiplayer

409
00:27:00,030 --> 00:27:00,820
is out.

410
00:27:00,840 --> 00:27:03,050
So let's go to the street uncreate Mefford.

411
00:27:03,270 --> 00:27:07,050
And here I can create a variable of type integer and the name of this value.

412
00:27:07,070 --> 00:27:15,000
But it's going to be first number first number and then I put an assignment operator here and in here

413
00:27:15,030 --> 00:27:23,710
I can say it is the first number that get fixed that two is three semicolon.

414
00:27:24,090 --> 00:27:27,900
So now as you can see we have an error and because this is actually the end it is invaluable.

415
00:27:27,900 --> 00:27:34,170
Here we are getting a string value so if you want to cast this value you want to just convert actually

416
00:27:34,410 --> 00:27:35,730
this value to an integer value.

417
00:27:35,730 --> 00:27:38,080
So we use the method of the integer class.

418
00:27:38,130 --> 00:27:39,530
So integer parsing.

419
00:27:39,540 --> 00:27:43,920
So you are already familiar with this method and this method accepts an argument of type stream and

420
00:27:43,920 --> 00:27:47,920
it's going to convert this value to an integer value here.

421
00:27:47,940 --> 00:27:51,160
So we actually put this value inside the pantless.

422
00:27:51,390 --> 00:27:57,180
So is the practices of this parsing Smurfit and now the error is gone let's create another rowdier but.

423
00:27:57,390 --> 00:28:01,580
Second number assignment operator.

424
00:28:01,650 --> 00:28:11,050
So integer parsing it has a number that takes that string semicolon.

425
00:28:11,340 --> 00:28:14,410
So now let's create another variable.

426
00:28:14,430 --> 00:28:16,730
The end result.

427
00:28:17,220 --> 00:28:18,030
Assignment operator.

428
00:28:18,040 --> 00:28:19,630
So let me scroll to the top here.

429
00:28:19,740 --> 00:28:25,560
You can see this interface at my interface so we can't actually access the method that we have inside

430
00:28:25,560 --> 00:28:26,750
this IDL file.

431
00:28:26,880 --> 00:28:31,820
This one and we actually provided an implementation for this method inside the service.

432
00:28:32,010 --> 00:28:37,410
So inside this main activity class and inside is Uncle Mefford we actually binded this service with

433
00:28:37,410 --> 00:28:38,800
this client here.

434
00:28:38,940 --> 00:28:44,400
So we created a connection between these services as you can see we provided this my service connection

435
00:28:44,400 --> 00:28:44,890
here right.

436
00:28:44,970 --> 00:28:48,520
So it's going to create a connection between the service and this idea right.

437
00:28:48,720 --> 00:28:53,090
And now these service is my interface it is now initialized.

438
00:28:53,100 --> 00:28:53,850
Right.

439
00:28:54,300 --> 00:28:59,720
So we declared disvalue but my interface and be initialized this rally about here inside this on service

440
00:28:59,720 --> 00:29:00,550
connected.

441
00:29:00,810 --> 00:29:01,430
Right.

442
00:29:01,500 --> 00:29:04,740
So now we have this interface here.

443
00:29:04,740 --> 00:29:05,990
So it's resolved.

444
00:29:06,020 --> 00:29:13,980
Assignment operator and here I can refer to this my interface and now I can see that multiply two values

445
00:29:13,980 --> 00:29:15,230
to get there.

446
00:29:15,240 --> 00:29:18,000
So now I can pass two arguments to dismiss it.

447
00:29:18,000 --> 00:29:21,820
So the first one is going to be for example the first number.

448
00:29:21,990 --> 00:29:25,890
So we get this value from the first actually editrix.

449
00:29:25,890 --> 00:29:28,530
So first number we have a type here.

450
00:29:28,530 --> 00:29:34,760
So the first number and we need to pass the second argument so second number semicolon.

451
00:29:35,010 --> 00:29:35,790
Right.

452
00:29:35,790 --> 00:29:37,820
So now we have actually an error.

453
00:29:37,830 --> 00:29:39,650
So let me show you what is this error.

454
00:29:39,660 --> 00:29:44,890
Let's actually hover over the scanner here and says unhandled exception Android that.

455
00:29:44,910 --> 00:29:46,740
Or is that remote exception.

456
00:29:46,740 --> 00:29:49,260
So now let me show you why we have this exception.

457
00:29:49,350 --> 00:29:51,140
So let's go to this idea file.

458
00:29:51,360 --> 00:29:53,640
As you can see we declared this method here.

459
00:29:53,640 --> 00:29:54,030
Right.

460
00:29:54,180 --> 00:29:57,110
But we provide it at implementation for this method.

461
00:29:57,270 --> 00:30:00,120
Inside this model application said we start Java.

462
00:30:00,450 --> 00:30:05,240
So here look at this piece of code here inside this block of code.

463
00:30:05,250 --> 00:30:07,700
You can see that we actually overwrite it dismiss it.

464
00:30:07,740 --> 00:30:09,200
Multiply two values together.

465
00:30:09,270 --> 00:30:13,070
So we get dismembered from this interface must multiply interface.

466
00:30:13,260 --> 00:30:16,620
And now you can see that it actually froze an exception.

467
00:30:16,620 --> 00:30:22,530
This is really important so because the sniffer froze and it's an exception and it is called the remote

468
00:30:22,530 --> 00:30:23,360
exception.

469
00:30:23,570 --> 00:30:27,050
The Actually must handle this exception.

470
00:30:27,060 --> 00:30:31,130
Otherwise the compiler is not going to allow us to run our application.

471
00:30:31,170 --> 00:30:32,630
So let's go to main activity here.

472
00:30:32,630 --> 00:30:34,720
And inside is actually Smurfette here.

473
00:30:34,860 --> 00:30:41,330
Before this line of code here is actually just typing try I can provide a try block here.

474
00:30:41,670 --> 00:30:48,090
I can't try and then put a catch block and that here inside the parenthesis of this catch here I can

475
00:30:48,090 --> 00:30:50,070
say REMAUT exception.

476
00:30:50,160 --> 00:30:52,740
So you know what is the name of that exception.

477
00:30:52,740 --> 00:30:53,090
Right.

478
00:30:53,160 --> 00:30:56,780
So because inside is so multiplication so we start over.

479
00:30:56,850 --> 00:30:59,040
You can see the name of this exception.

480
00:30:59,190 --> 00:31:01,120
So let's go to the main issue with the Java here.

481
00:31:01,160 --> 00:31:02,310
And inside the sunken ship.

482
00:31:02,460 --> 00:31:06,570
So the type is more the exception and the name is eat right.

483
00:31:06,750 --> 00:31:10,360
And here again just open and close this catch block by using these curly braces.

484
00:31:10,530 --> 00:31:17,280
And here let's just select this line of code here and just cut this line of code and just paste this

485
00:31:17,280 --> 00:31:19,590
line of Cahir inside is try block.

486
00:31:19,800 --> 00:31:20,430
Right.

487
00:31:20,640 --> 00:31:22,480
And now the air is gone.

488
00:31:22,500 --> 00:31:25,240
So now we have this valuable result.

489
00:31:25,260 --> 00:31:30,420
My interface that Multiplex Jubilees together and now we're actually handling this exception because

490
00:31:30,420 --> 00:31:32,030
we put it inside is triplex.

491
00:31:32,220 --> 00:31:34,560
So if we can actually just print.

492
00:31:34,710 --> 00:31:39,170
So here I can say Eat Eat at a print stack trace.

493
00:31:39,340 --> 00:31:39,970
Right.

494
00:31:40,020 --> 00:31:46,340
So we can just print these values to the larg later when I should and Eric Harris.

495
00:31:46,370 --> 00:31:47,910
So we have this right here.

496
00:31:48,020 --> 00:31:54,950
And here I can insert this tripe like I can say TXI the multiply these are the set text.

497
00:31:55,010 --> 00:31:59,720
And here I can refer to the name of this rally about a result but because this is actually an integer

498
00:31:59,870 --> 00:32:06,830
value and if it needs are valuable a value of type string I can convert this value to string value by

499
00:32:06,830 --> 00:32:11,520
just putting a plus operator and then put to double quotes here.

500
00:32:11,540 --> 00:32:15,840
So now let's run our project and see what happens.

501
00:32:18,070 --> 00:32:19,340
Let me show you the emulator.

502
00:32:19,360 --> 00:32:24,210
So now as you can see here my application is running on this emulator.

503
00:32:24,250 --> 00:32:26,320
So now we need to provide the first value.

504
00:32:26,390 --> 00:32:31,120
So the first value is going to be number 10 and the second value is going to be number.

505
00:32:31,120 --> 00:32:32,580
For example again 10.

506
00:32:32,830 --> 00:32:34,230
So let's click on the.

507
00:32:34,720 --> 00:32:36,430
And we have number 100.

508
00:32:36,670 --> 00:32:39,400
So let's change the first value to 5.

509
00:32:39,580 --> 00:32:43,620
And the second value 2 numbers to right let's click on this button again.

510
00:32:43,720 --> 00:32:49,570
And now we have numbered 10 or less change the first value to number three and click on this button.

511
00:32:49,570 --> 00:32:51,290
Now we have number six.

512
00:32:51,340 --> 00:32:56,670
So now you can see that how we used this IDL in Android.

513
00:32:56,710 --> 00:33:03,520
So I think now you can actually figure out how to use a million Android and if you have any questions

514
00:33:03,520 --> 00:33:08,650
about these concepts that I taught you in this lesson please post the discussion in the course and then

515
00:33:08,660 --> 00:33:10,800
I'll do my best to answer all of your questions.

516
00:33:10,810 --> 00:33:13,820
Thank you very much for watching and I'll see you in the next Steve Tauriel.

