1
00:00:00,480 --> 00:00:06,700
So here as you can see I the access modifier of my my if it is public this method is static.

2
00:00:06,750 --> 00:00:07,270
OK.

3
00:00:07,470 --> 00:00:16,040
And the return type of this method is void and the name of my method is to verify that we can call someone

4
00:00:16,520 --> 00:00:20,810
and this this it actually accepts an argument of type activity.

5
00:00:20,970 --> 00:00:25,570
So here inside the Smurfit as you can see I have these lines of code.

6
00:00:25,890 --> 00:00:32,550
And first of all in line 20 as you can see here I have a variable of type integer and the name of this

7
00:00:32,550 --> 00:00:34,300
roundtable is permission.

8
00:00:34,590 --> 00:00:42,300
So here I actually referred to the name of this activity compact class activity compact that check self

9
00:00:42,300 --> 00:00:43,200
permission.

10
00:00:43,410 --> 00:00:49,560
Ok here I want to check whether I can access the call feature of the device or not check self permission

11
00:00:49,800 --> 00:00:52,340
and this method actually to accept two arguments.

12
00:00:52,440 --> 00:00:56,930
The first one is the activity that we have as an argument of our Meffert.

13
00:00:57,180 --> 00:01:03,300
And the second one is the permission that we are able to access manifest that permission the Khalfan.

14
00:01:03,500 --> 00:01:04,200
OK.

15
00:01:04,470 --> 00:01:06,970
And here I have an if statement.

16
00:01:07,020 --> 00:01:07,980
As you can see here.

17
00:01:08,130 --> 00:01:15,060
So if permission is not equal to package manager that permission granted.

18
00:01:15,180 --> 00:01:22,090
Ok so if we don't have the permission that the user would allow me to do that.

19
00:01:22,110 --> 00:01:22,600
OK.

20
00:01:22,770 --> 00:01:28,190
So if the user wouldn't allow me to access the call feature of the device.

21
00:01:28,230 --> 00:01:30,810
OK so this is the meaning of this piece of code here.

22
00:01:31,080 --> 00:01:35,400
If permission is not equal to package manager that permission granted.

23
00:01:35,520 --> 00:01:42,300
If we don't have access to that permission OK if the user wouldn't allow me to actually use the call

24
00:01:42,300 --> 00:01:43,770
feature of the device.

25
00:01:43,950 --> 00:01:46,220
And as you can see here I created the comment here.

26
00:01:46,320 --> 00:01:49,210
We don't have the permission to so prompt the user.

27
00:01:49,230 --> 00:01:51,520
So now I'm on to ask the user.

28
00:01:51,720 --> 00:01:52,190
OK.

29
00:01:52,380 --> 00:01:57,140
I want to ask the user to allow me to access the call feature of the device.

30
00:01:57,150 --> 00:01:57,690
OK.

31
00:01:57,750 --> 00:02:01,540
Activity compact that requires the permissions.

32
00:02:01,540 --> 00:02:08,220
So if it actually accepts free arguments the first one is the activity the second one is the permissions

33
00:02:08,310 --> 00:02:11,100
Aure that we want to actually ask the user.

34
00:02:11,100 --> 00:02:13,530
So here is the permissions Aure.

35
00:02:13,890 --> 00:02:16,540
And the first one is the request code.

36
00:02:16,650 --> 00:02:19,050
So I have this request called call here.

37
00:02:19,290 --> 00:02:20,910
OK.

38
00:02:21,030 --> 00:02:28,410
Now here inside our uncreate Smurfette I want to actually call the Smurfette verify that we can call

39
00:02:28,410 --> 00:02:29,060
someone.

40
00:02:29,160 --> 00:02:33,720
So here I can't just type in verify that they can call someone.

41
00:02:33,870 --> 00:02:41,820
And for the activity I can just type in here main activity that's this.

42
00:02:42,290 --> 00:02:47,490
OK so now let's actually run our project and see what happens.

43
00:02:47,490 --> 00:02:55,290
So now as you can see our application is running on this emulator here and here you can see now it is

44
00:02:55,290 --> 00:03:01,870
asking me that this allow app 45 to make and manage phone calls.

45
00:03:02,160 --> 00:03:09,790
So it is asking the user do you want to allow this application to make and manage phone calls.

46
00:03:09,990 --> 00:03:18,030
If I hit on allow here OK I can actually call someone if I hit on the night here I would not be able

47
00:03:18,030 --> 00:03:19,680
to call someone.

48
00:03:19,680 --> 00:03:28,030
So here I can actually select this allow here and now I can call someone in my application.

49
00:03:28,080 --> 00:03:32,850
So let's actually go back to my main activity here and it's actually at some more lines of code here

50
00:03:33,090 --> 00:03:38,610
because at the moment our application wouldn't do so much in here because if I click on these buttons

51
00:03:38,610 --> 00:03:42,480
here now you can see that we cannot actually do anything here.

52
00:03:42,480 --> 00:03:46,620
So we need to put those logic's inside our main activity class.

53
00:03:46,770 --> 00:03:51,840
So now I'm going to pasting some lines of code here and then I'm going to explain to you what's going

54
00:03:51,840 --> 00:03:52,950
on here.

55
00:03:52,980 --> 00:03:57,810
So as you can see here these are the lines of code that they actually place that inside this main activity

56
00:03:57,810 --> 00:03:58,360
class.

57
00:03:58,410 --> 00:03:59,010
OK.

58
00:03:59,010 --> 00:04:05,970
So first of all I actually declared the spot in BT and would give me bt between our search Google BT

59
00:04:05,970 --> 00:04:08,470
and Karl and Pythian access DeLaet.

60
00:04:08,490 --> 00:04:13,770
So inside these uncreate Mefford after this line of code here verified that they can't call someone

61
00:04:13,980 --> 00:04:19,970
here Ivonne to instantiate these but that I declared inside the main activity class.

62
00:04:19,980 --> 00:04:27,840
So here I can just typing PTEN or Penni you the assignment operator and here I can just actually pass

63
00:04:27,840 --> 00:04:38,730
this object to on to the button object find view by ID or that Id that PTEN open you the semicolon between

64
00:04:39,060 --> 00:04:42,380
search Google assignment operator here.

65
00:04:42,390 --> 00:04:50,190
I just need to cast this object to a button object find view by ID or that Id dot between Google search

66
00:04:50,280 --> 00:04:53,710
search Google semi-colon and are here.

67
00:04:53,730 --> 00:05:00,460
I just need to type in PTEN Col assignment operator Potin find.

68
00:05:00,470 --> 00:05:12,220
View by id artist Id dot PTEN Col semicolon between Access Dyott had assignment operator and here I

69
00:05:12,220 --> 00:05:21,070
need to cast this object to a button object find view by id r that ID that Pythian access dial pad semicolon.

70
00:05:21,170 --> 00:05:27,790
OK so now here I want to actually make these buttons a listener to the clicks of the user.

71
00:05:27,790 --> 00:05:32,720
OK so that our application would respond if the user touches one of these buttons.

72
00:05:32,740 --> 00:05:34,870
So here I can just type in between.

73
00:05:35,110 --> 00:05:43,630
Open you the me that set on click listener and here I need to pass the context main activity that this.

74
00:05:44,000 --> 00:05:45,820
OK so this is our context.

75
00:05:46,000 --> 00:05:52,400
And again I have this beauty and search Google so I can't just typing Pythia and search Google.

76
00:05:52,480 --> 00:05:55,270
That said Anchal listener.

77
00:05:55,820 --> 00:05:56,370
OK.

78
00:05:56,590 --> 00:06:06,920
Main activity that this and here again we have this beauty and called PTEN Karl data set on calculus

79
00:06:06,930 --> 00:06:18,480
and our main activity thought this here again we have this BT an Access style pad between access dial

80
00:06:18,480 --> 00:06:26,010
pad that said on click listener main activity that is OK.

81
00:06:26,310 --> 00:06:31,440
So here as you can see we have some errors and that's because of this interface we need to actually

82
00:06:31,470 --> 00:06:33,950
implement the unclick list in an interface.

83
00:06:33,960 --> 00:06:37,450
So here I can just typing after this compact activity here.

84
00:06:37,590 --> 00:06:45,160
I can't just type in implements view thoughts on click listener.

85
00:06:45,320 --> 00:06:50,930
So now again we have an error so we need to actually implement the uncle Smurfette in our main activity

86
00:06:50,930 --> 00:06:51,350
class.

87
00:06:51,350 --> 00:06:57,480
So here I can't just typing on Cliq and as you can see here is showing us this method here so I can

88
00:06:57,480 --> 00:07:04,280
just press enter key here and now we have this method here public Voyt and click method.

89
00:07:04,310 --> 00:07:09,980
So here as you can see if you have an argument of type view so the name of this argument is not good

90
00:07:10,070 --> 00:07:10,700
here.

91
00:07:10,700 --> 00:07:13,010
So I can't just change it to view.

92
00:07:13,180 --> 00:07:21,320
OK so here because I want to differentiate between clicking of these buttons here I just need to create

93
00:07:21,320 --> 00:07:26,560
a switch statement and I want to switch between the IDs of these buttons.

94
00:07:26,570 --> 00:07:30,180
So here I can just type in view that gets ID.

95
00:07:30,470 --> 00:07:30,930
OK.

96
00:07:31,100 --> 00:07:35,090
And then I need to actually open and close this switch statement.

97
00:07:35,090 --> 00:07:40,910
So here I can just type in our thought Id dot between open you'd see me.

98
00:07:41,060 --> 00:07:48,780
So if the user clicks or touches that BT and the button here I have this logic here.

99
00:07:48,890 --> 00:07:53,180
So here I actually forgot to put the case statement here.

100
00:07:53,180 --> 00:08:00,530
Case r that ID that Pythian open Eudemus So if the user clicks on a BT and open you me then it's going

101
00:08:00,530 --> 00:08:01,350
to respond.

102
00:08:01,520 --> 00:08:02,860
We have other cases too.

103
00:08:02,870 --> 00:08:08,660
So case are thought Id that Google search BT and search Google.

104
00:08:08,900 --> 00:08:11,630
OK colon break.

105
00:08:12,320 --> 00:08:18,550
And we have another case case are that Id dot PTEN.

106
00:08:18,770 --> 00:08:29,480
Carl Sullivan here as you can see Colan break case Artaud already thought between access they L-pad

107
00:08:29,870 --> 00:08:31,640
colon break.

108
00:08:32,210 --> 00:08:36,110
So here I want to put the logic here for these patents.

109
00:08:36,170 --> 00:08:40,970
So for this are BT and open to me here I want to paste in some lines of code here and then I'm going

110
00:08:40,970 --> 00:08:43,330
to explain to you what's going on here.

111
00:08:43,340 --> 00:08:47,820
So as you can see here these are the lines of code that I actually pasted here.

112
00:08:47,840 --> 00:08:52,830
First of all I created an object of type intent and the name of this object is intent.

113
00:08:52,850 --> 00:08:55,190
And here I put an assignment operator.

114
00:08:55,190 --> 00:09:02,210
So here I want to instantiate this intent object new intent and inside the prentices I want to specify

115
00:09:02,210 --> 00:09:05,650
that what that what would I want to do with this intent.

116
00:09:05,660 --> 00:09:12,230
So I want this intense tragedy open of a browser and then go straight ahead to Eudemus dot com.

117
00:09:12,320 --> 00:09:12,880
OK.

118
00:09:12,890 --> 00:09:18,920
So in order to do that job I need to actually call this intent that action view OK I want to actually

119
00:09:18,920 --> 00:09:22,860
open up a website in a web browser in my device.

120
00:09:22,940 --> 00:09:25,510
So I need to call this intent that action view.

121
00:09:25,970 --> 00:09:32,120
And here in the second line in line 81 as you can see we have this intent object that said data.

122
00:09:32,120 --> 00:09:34,740
So here I want to I need to actually specify the data.

123
00:09:34,760 --> 00:09:35,270
OK.

124
00:09:35,420 --> 00:09:36,480
You are.

125
00:09:36,750 --> 00:09:37,220
OK.

126
00:09:37,310 --> 00:09:39,740
I call this you or I class that parse.

127
00:09:39,800 --> 00:09:44,420
Hush TTP dot hostilely colon slash slash.

128
00:09:44,480 --> 00:09:47,400
W w w dot you see me dot com.

129
00:09:47,420 --> 00:09:48,100
OK.

130
00:09:48,110 --> 00:09:53,870
And here as you can see I call this Meffert start activity intent.

131
00:09:53,870 --> 00:09:56,660
So it's actually on our project and see what happens.

132
00:09:56,660 --> 00:10:01,240
So now as you can see our application is running on this emulator here.

133
00:10:01,340 --> 00:10:05,540
So if I actually click on this button here let's open you with me that's come let's see what happens.

134
00:10:07,210 --> 00:10:11,520
And as you can see it's now opening to you to me datacom for me.

135
00:10:11,640 --> 00:10:11,930
OK.

136
00:10:11,930 --> 00:10:14,380
In my web browser.

137
00:10:14,570 --> 00:10:17,420
So he had to be 10 cities Eudemus dot com.

138
00:10:17,570 --> 00:10:18,130
OK.

139
00:10:19,050 --> 00:10:21,110
So hopefully that makes sense.

140
00:10:21,300 --> 00:10:24,090
So let's us actually click on the back button here.

141
00:10:24,120 --> 00:10:26,550
Now I want to actually search the Google.

142
00:10:26,730 --> 00:10:28,460
So let's actually put that logic here.

143
00:10:28,500 --> 00:10:32,100
In this case statement here between search Google.

144
00:10:32,100 --> 00:10:34,770
So here I am able to actually paste in some lines of code.

145
00:10:34,800 --> 00:10:39,090
So as you can see here these are the lines of code that I actually paste that here.

146
00:10:39,090 --> 00:10:45,180
First of all again I actually created an object of type intent and the name of this object is intent

147
00:10:45,270 --> 00:10:47,250
to assignment operator.

148
00:10:47,250 --> 00:10:53,530
So here I am instantiating this intent object and inside the prentices because I want to actually search

149
00:10:53,550 --> 00:10:54,200
the verb.

150
00:10:54,360 --> 00:10:57,190
I actually called intent that action a web search.

151
00:10:57,300 --> 00:10:57,910
OK.

152
00:10:58,230 --> 00:11:01,570
And here I have this intent to object that set data.

153
00:11:01,800 --> 00:11:03,730
You are right that parse.

154
00:11:03,930 --> 00:11:08,820
And instead of double quotes I just typed in hushed ETP colon slash slash.

155
00:11:09,000 --> 00:11:11,350
W w w dot Google dot com.

156
00:11:11,480 --> 00:11:12,120
OK.

157
00:11:12,150 --> 00:11:16,410
And here I call this my first start activity intent too.

158
00:11:16,520 --> 00:11:19,080
So let's run our project and see what happens.

159
00:11:19,080 --> 00:11:24,710
So now as you can see our application is running Andi's emulator.

160
00:11:24,840 --> 00:11:25,580
OK.

161
00:11:25,950 --> 00:11:28,810
And here as you can see I want to actually click on this.

162
00:11:28,830 --> 00:11:31,040
Let's search the Google.

163
00:11:31,380 --> 00:11:37,120
And now as you can see it opened the website and now I can actually search the google here.

164
00:11:37,410 --> 00:11:38,210
OK.

165
00:11:38,730 --> 00:11:40,270
As you can see here.

166
00:11:40,410 --> 00:11:42,380
So hopefully that makes sense.

167
00:11:42,380 --> 00:11:47,650
So let me actually click on dispatch button here and here I want to call someone.

168
00:11:47,700 --> 00:11:49,590
Ok this is very important.

169
00:11:49,590 --> 00:11:54,850
So let's actually go back to our main activity class and put that logic here end card.

170
00:11:54,990 --> 00:12:00,330
So here I'm going to paste in some lines of code and then I'm going to explain to you what's going on

171
00:12:00,330 --> 00:12:01,290
here.

172
00:12:01,320 --> 00:12:07,440
So as you can see here these are the lines of code that I actually paste that here and here as you can

173
00:12:07,440 --> 00:12:12,280
see I created an if statement if context compact.

174
00:12:12,370 --> 00:12:12,640
OK.

175
00:12:12,660 --> 00:12:14,500
That takes self permission.

176
00:12:14,770 --> 00:12:15,080
OK.

177
00:12:15,090 --> 00:12:20,250
Because I want to actually call someone we need to first ask the user of whether they would allow me

178
00:12:20,550 --> 00:12:24,260
whether they would allow the application or to call someone or not.

179
00:12:24,270 --> 00:12:24,770
OK.

180
00:12:25,050 --> 00:12:28,170
If context compact that check self permission.

181
00:12:28,170 --> 00:12:33,800
So here we need to actually for the first argument Vini to specify this the context.

182
00:12:33,810 --> 00:12:40,530
So I could just type in main activity that is OK for this and here for the sake of argument we need

183
00:12:40,530 --> 00:12:44,370
to specify the permission that we want to actually access.

184
00:12:44,420 --> 00:12:48,690
OK manifest that permission does Carl form.

185
00:12:48,930 --> 00:12:49,620
OK.

186
00:12:49,890 --> 00:12:53,460
As you can see here manifest that permission that Khalfan.

187
00:12:53,460 --> 00:13:00,010
So if this permission is not equal to package manager that permission granted OK.

188
00:13:00,210 --> 00:13:08,240
If the user if the user didn't allow me to access the Khalfan feature of my device of their device OK.

189
00:13:08,580 --> 00:13:16,050
If my application is not allowed to access the call a feature of the device.

190
00:13:16,080 --> 00:13:16,350
OK.

191
00:13:16,350 --> 00:13:23,460
If the user didn't allow me to access the card feature here I want to ask them again activity compacts

192
00:13:23,760 --> 00:13:25,760
that request permissions first.

193
00:13:25,760 --> 00:13:31,730
Again I any to specify the context for here instead of this I could just type in main activity that

194
00:13:31,780 --> 00:13:35,860
this and for the second argument we need to specify the permissions.

195
00:13:35,940 --> 00:13:36,960
News strange.

196
00:13:37,020 --> 00:13:42,780
And here as you can see I have an array of type strange object as you can see I created an array of

197
00:13:42,780 --> 00:13:50,040
string object and inside that array I have this value manifest that permission that Khalfan and for

198
00:13:50,040 --> 00:13:53,670
the first argument we need to specify the request code card.

199
00:13:54,300 --> 00:13:55,390
As you can see here.

200
00:13:55,680 --> 00:14:01,590
So here I actually ask the user whether they would allow me to access the call feature of the device

201
00:14:01,620 --> 00:14:02,350
or not.

202
00:14:02,580 --> 00:14:03,100
OK.

203
00:14:03,180 --> 00:14:08,080
If they would allow me then I am allowed to actually access that feature.

204
00:14:08,250 --> 00:14:11,080
So here I have an else statement.

205
00:14:11,100 --> 00:14:16,320
If so if the user doesn't allow me to access the call feature OK then it's going to actually execute

206
00:14:16,320 --> 00:14:17,340
this line of code here.

207
00:14:17,460 --> 00:14:24,940
But if I have permission to access the call feature then it's going to execute this else statement.

208
00:14:24,960 --> 00:14:25,420
OK.

209
00:14:25,560 --> 00:14:32,010
Intent intent free Neil intent intent that action card.

210
00:14:32,250 --> 00:14:32,940
OK.

211
00:14:33,120 --> 00:14:34,910
So here this is the action card.

212
00:14:35,220 --> 00:14:40,490
And here again I referred to the name of this object intent free that said they tell you outright that

213
00:14:40,530 --> 00:14:42,980
parts and inside the double quotes.

214
00:14:43,060 --> 00:14:47,280
I just need to specify the number that you want to call.

215
00:14:47,290 --> 00:14:49,750
OK the phone number that I want to call.

216
00:14:49,750 --> 00:14:54,280
So here I just need to put this tell here tell call in.

217
00:14:54,300 --> 00:14:56,740
So this is an important Tell call in.

218
00:14:56,820 --> 00:15:00,660
And here it is going to be the phone number that you want to call.

219
00:15:01,040 --> 00:15:05,650
And here as you can see I call this my fifth start activity intensively.

220
00:15:05,940 --> 00:15:08,790
So let's run our project and see what happens.

221
00:15:08,790 --> 00:15:13,330
So here as you can see our application is running on this emulator here.

222
00:15:13,470 --> 00:15:18,260
So now I want to actually call someone let's So here let's actually click on this button here.

223
00:15:18,460 --> 00:15:20,620
Let's call someone.

224
00:15:20,980 --> 00:15:24,920
And now as you can see I am calling someone with this number.

225
00:15:25,240 --> 00:15:25,730
OK.

226
00:15:25,840 --> 00:15:28,080
So hopefully that makes sense.

227
00:15:28,090 --> 00:15:30,780
And let's actually click on this back button here.

228
00:15:30,820 --> 00:15:33,640
So now I want to access the dial pad.

229
00:15:33,640 --> 00:15:34,150
OK.

230
00:15:34,300 --> 00:15:39,340
So let's actually go back to our main activity the java file here and let's actually put that logic

231
00:15:39,340 --> 00:15:41,780
here bt an access dial pad.

232
00:15:41,950 --> 00:15:46,330
So here I'm going on pasting some lines of code and then I'm going to explain to you what's going on

233
00:15:46,330 --> 00:15:46,980
here.

234
00:15:46,990 --> 00:15:51,540
So as you can see here these are the two lines of code that they actually paste that here.

235
00:15:51,790 --> 00:15:58,540
So here I created an object of type intent and the name of this intent is our intent for this intent

236
00:15:58,600 --> 00:16:00,900
object assignment operator.

237
00:16:00,910 --> 00:16:07,600
So here I actually instantiated this object new intent and in say The Apprentice's I specified that

238
00:16:07,650 --> 00:16:09,950
I want to access the actual Dayal.

239
00:16:10,050 --> 00:16:10,350
OK.

240
00:16:10,360 --> 00:16:11,370
Intent that action.

241
00:16:11,380 --> 00:16:17,210
Daniel and here I call the Smurfette starved activity intent forth.

242
00:16:17,260 --> 00:16:21,190
So now let's actually run our project and see what happens.

243
00:16:21,190 --> 00:16:26,160
So as you can see here now our application is running on this simulator here.

244
00:16:26,290 --> 00:16:28,600
Let's access that dial pad.

245
00:16:28,600 --> 00:16:35,830
So let's actually click on this button here and now as you can see I can actually access the dial pad

246
00:16:35,830 --> 00:16:36,600
here.

247
00:16:36,960 --> 00:16:37,550
OK.

248
00:16:38,620 --> 00:16:46,280
So here if I actually click on the spot in here now I can access the dial pad or do something else.

249
00:16:46,300 --> 00:16:49,620
As you can see here and call someone.

250
00:16:49,980 --> 00:16:50,490
OK.

251
00:16:51,400 --> 00:16:57,160
So hopefully that makes sense and I think that's enough for this tutorial.

252
00:16:57,160 --> 00:17:03,220
So if you have any questions please post the discussion in the course and then I'll do my best to answer

253
00:17:03,250 --> 00:17:04,430
all of your questions.

254
00:17:04,570 --> 00:17:08,330
Thank you very much for watching and I'll see you in the next year Tauriel.

