1
00:00:00,620 --> 00:00:09,470
Let's go ahead and create a listener for this PTEN take the picture Potten so I can say PTEN take a

2
00:00:09,470 --> 00:00:15,450
picture that said unclick listener Pythian that take a picture.

3
00:00:15,760 --> 00:00:21,070
That's what I collect listener and now I need to pass the context so I can just pass an activity that

4
00:00:21,070 --> 00:00:21,850
is.

5
00:00:22,020 --> 00:00:28,610
So the main activity that this is going to be actually a listener when the user interacts with is spartan.

6
00:00:28,850 --> 00:00:35,030
So in order for this main activity class to be the listener in order to be notified whenever they use

7
00:00:35,030 --> 00:00:42,230
that interacts with this PTEN taking part in this class must implement their unclick listener interface.

8
00:00:42,230 --> 00:00:44,100
So you're already familiar with that right.

9
00:00:44,180 --> 00:00:49,520
So I just need to scroll to the top and here it says main activity extends app compacter activity.

10
00:00:49,580 --> 00:00:56,760
And here I can say space implements view dot and click click center.

11
00:00:57,200 --> 00:01:02,500
So the idea that this class is actually implementing this view that unclick this in an interface this

12
00:01:02,500 --> 00:01:05,930
class must provide an implementation for the unclick my foot.

13
00:01:05,930 --> 00:01:07,200
So let's scroll down here.

14
00:01:07,280 --> 00:01:12,260
And after the end in curly brace of this uncreate method and before the end and curly brace of this

15
00:01:12,410 --> 00:01:16,980
main activity class I had just been unclick and that person interchange keyboard.

16
00:01:17,000 --> 00:01:19,120
So now we are all we're writing this.

17
00:01:19,130 --> 00:01:23,090
Unclear if an insider view that unclick the center interface.

18
00:01:23,180 --> 00:01:26,270
So whenever that is that actually interacts with the SBT and take a picture.

19
00:01:26,270 --> 00:01:29,450
But in this Smurfette here unclick is going to be called.

20
00:01:29,450 --> 00:01:29,860
Right.

21
00:01:30,050 --> 00:01:35,630
But because we have two buttons inside our application we have the first one BTA take a picture and

22
00:01:35,630 --> 00:01:38,210
the second one is PTEN save the picture.

23
00:01:38,210 --> 00:01:41,780
So let's also create a listener for this SBT and save the picture.

24
00:01:41,780 --> 00:01:47,300
So after this line of code that sets the listener for the spit take a picture or can just say PTEN safety

25
00:01:47,300 --> 00:01:51,040
feature that sits unclick listener.

26
00:01:52,370 --> 00:01:58,610
And here again I can just pass the context meant I think that that is so now because this class is actually

27
00:01:58,610 --> 00:02:02,270
conforming to this view that unclick us in an interface.

28
00:02:02,360 --> 00:02:06,940
And if you are providing MF Smurfit inside that interface here.

29
00:02:07,000 --> 00:02:12,350
So whenever they use it actually interacts with these two buttons into hip or Pythian save the picture

30
00:02:12,370 --> 00:02:13,840
this if it is going to be called.

31
00:02:13,880 --> 00:02:15,310
So you're already familiar with that.

32
00:02:15,310 --> 00:02:15,960
Right.

33
00:02:15,980 --> 00:02:18,990
So how we can actually differentiate between these two buttons.

34
00:02:19,190 --> 00:02:24,710
By using this view here it is you object that I to receive as an argument from the Songkhla if I can

35
00:02:25,010 --> 00:02:32,340
say this uncle if I can say if this is actually the name of this argument I can change the name of this

36
00:02:32,460 --> 00:02:33,490
argument to view.

37
00:02:33,570 --> 00:02:35,000
It's better to name it view.

38
00:02:35,190 --> 00:02:41,730
So if view that ID so let's actually get just a bit here.

39
00:02:41,790 --> 00:02:56,650
ID is equal to or data ID but Pythian take a picture then in that case here we are a hundred and fifty

40
00:02:56,840 --> 00:03:00,710
percent sure that is pretty and take a picture is actually clicked.

41
00:03:00,710 --> 00:03:06,440
So inside this statement you can actually put the logic that we want to be executed Whenever to use

42
00:03:06,440 --> 00:03:10,730
that interacts with this and take a picture so I can create an ELSE IF statement here.

43
00:03:10,730 --> 00:03:17,960
So after the head curly brace of this if statement I can say Elsy else if inside the apprentice's I

44
00:03:17,960 --> 00:03:29,300
can say view that get Id get ID right and then put an equal operator here Aard thought id that Pythian

45
00:03:29,300 --> 00:03:36,410
save the picture here and here you are 100 I'm 50 percent sure that this beauty and save the picture

46
00:03:36,410 --> 00:03:37,370
is actually clicked.

47
00:03:37,370 --> 00:03:39,680
So it is going to ask you this if statement.

48
00:03:39,680 --> 00:03:45,560
So how this is how we can actually differentiate between Actually these buttons.

49
00:03:45,590 --> 00:03:48,320
So let's go inside the curly braces of this statement.

50
00:03:48,340 --> 00:03:52,880
If you view that it is R that R D that BT and take a picture.

51
00:03:52,880 --> 00:04:01,620
Now I can say so here because we want to actually get the user's permission in order to access the camera.

52
00:04:01,880 --> 00:04:03,170
It is very important.

53
00:04:03,170 --> 00:04:04,110
It is a must actually.

54
00:04:04,220 --> 00:04:08,480
To ask the user in order to get the permission to access the camera.

55
00:04:08,540 --> 00:04:10,810
So we must actually ask the user for that.

56
00:04:10,810 --> 00:04:17,650
So just type in here in it and the name of this variable is going to be permeation result permission

57
00:04:18,060 --> 00:04:19,190
resolved.

58
00:04:19,580 --> 00:04:29,080
Assignment operator context compact context compact that a check self permission.

59
00:04:29,160 --> 00:04:35,170
So here first we need to pass the context which is going to be main activity that this comma.

60
00:04:35,490 --> 00:04:43,050
And for the second argument we need to say manifest such as they've been here manifest that permission

61
00:04:43,560 --> 00:04:45,650
DOT camera.

62
00:04:45,750 --> 00:04:50,360
So we want to ask the user to give us the permission to access the camera.

63
00:04:50,580 --> 00:04:53,210
So we need to also put this permission inside the manifest file.

64
00:04:53,220 --> 00:04:58,890
Let's actually open the address structure here at the top and you just click on View and then tool windows

65
00:04:58,920 --> 00:05:01,070
and then click on project here.

66
00:05:01,080 --> 00:05:02,830
This is our Android view right.

67
00:05:03,060 --> 00:05:06,390
So you can see this inside this app folder we have this manifests.

68
00:05:06,420 --> 00:05:07,810
So just double click on it.

69
00:05:08,010 --> 00:05:12,060
And here if you open this for the audience it is our manifest that is him on file.

70
00:05:12,300 --> 00:05:14,100
So inside this manifest.

71
00:05:14,100 --> 00:05:14,650
Hi.

72
00:05:14,770 --> 00:05:15,260
OK.

73
00:05:15,300 --> 00:05:19,390
Before this application here and inside its manifest manifest.

74
00:05:19,530 --> 00:05:24,020
Let me actually just double click on this tab in order to make this area either just open a tag and

75
00:05:24,030 --> 00:05:27,220
just type in here user's permission.

76
00:05:27,420 --> 00:05:29,430
So the permission is going to be camera.

77
00:05:29,460 --> 00:05:29,980
Right.

78
00:05:30,150 --> 00:05:32,800
So just they've been here and read the permission of the camera.

79
00:05:33,000 --> 00:05:39,840
And then just sell clothes this tag by using this slash and this and tag here.

80
00:05:39,840 --> 00:05:44,060
So now you are actually putting this permission here let's go to them in the class.

81
00:05:44,100 --> 00:05:47,360
So here we are checking for that condition for that permission.

82
00:05:47,370 --> 00:05:52,110
We are taking that if the permission is actually given to us by the user.

83
00:05:52,320 --> 00:05:57,660
Then the result is going to be actually assigned to this valuable permission or as a result.

84
00:05:57,870 --> 00:05:59,990
So let's create an if statement here.

85
00:06:00,030 --> 00:06:08,580
After this line of code after this valuable so I can say if permission result is equal to package manager

86
00:06:09,390 --> 00:06:16,880
that permission granted I can just open and close this statement by using these curly braces.

87
00:06:16,880 --> 00:06:23,960
Now I can say that the user has given us to access the camera so it is possible to actually access the

88
00:06:23,960 --> 00:06:27,680
camera right but we need to actually check for another condition.

89
00:06:27,680 --> 00:06:30,250
What if the user doesn't have the camera.

90
00:06:30,260 --> 00:06:32,620
What if the user's device doesn't have a camera.

91
00:06:32,870 --> 00:06:40,110
So for that case you also must create an if statement in order to check for that specific condition.

92
00:06:40,130 --> 00:06:43,760
So this if statement is checking for their permission granted.

93
00:06:43,760 --> 00:06:44,280
Right.

94
00:06:44,300 --> 00:06:48,990
So what happens if the user doesn't allow us to actually access the camera.

95
00:06:49,010 --> 00:06:53,920
In that case we want to actually ask the user to give us the permission to access the camera.

96
00:06:54,080 --> 00:06:59,850
So after this if statement after the end curly brace of this if statement if statement I can't say as

97
00:07:00,540 --> 00:07:04,640
I don't like could open and close this statement by using these curly braces so that I can actually

98
00:07:04,640 --> 00:07:12,390
request that I can say Let me just paste this line of quote here so you can see activity compact that

99
00:07:12,390 --> 00:07:14,180
requires the permissions.

100
00:07:14,560 --> 00:07:19,180
So first we need to pass the context which is going to be main activity that this and for the second

101
00:07:19,180 --> 00:07:26,320
argument we need to pass an ad a string values that actually holds the permissions that we want to actually

102
00:07:26,800 --> 00:07:27,740
ask the user.

103
00:07:27,940 --> 00:07:32,730
So we want to use user only allow us to access the cameras so we have only an outrage.

104
00:07:32,740 --> 00:07:36,080
So News Stream at 8:00 that this audio only has one value.

105
00:07:36,130 --> 00:07:36,870
Right.

106
00:07:36,910 --> 00:07:41,120
So instead of Colibri inside the curly braces you can see that we have this permanent manifest that

107
00:07:41,130 --> 00:07:42,330
we're in that camera.

108
00:07:42,520 --> 00:07:46,540
And for the second argument you can see it is actually this request the court.

109
00:07:46,690 --> 00:07:52,120
So this request card is used for actually requesting their permission.

110
00:07:52,120 --> 00:07:57,100
So it is one case it doesn't really matter what you put here but it must be a unique value a unique

111
00:07:57,100 --> 00:07:57,580
number.

112
00:07:57,580 --> 00:07:59,290
So what is ok here.

113
00:07:59,290 --> 00:08:01,080
So let's go inside this statement.

114
00:08:01,200 --> 00:08:06,590
So if they use that actually has given us the permission to access the camera I can't say.

115
00:08:06,730 --> 00:08:10,830
So first of all we need to access the package manager so I can't say enough.

116
00:08:10,870 --> 00:08:12,160
So here I am.

117
00:08:12,250 --> 00:08:13,960
First of all let's create a body.

118
00:08:13,970 --> 00:08:20,020
But of the package manager or package manager package manager assignment operator gets package manager

119
00:08:20,160 --> 00:08:20,950
semicolon.

120
00:08:21,240 --> 00:08:21,850
Right.

121
00:08:21,880 --> 00:08:28,360
So in this way we are actually accessing the package manager of the application that has the specific

122
00:08:28,360 --> 00:08:29,440
features of the device.

123
00:08:29,440 --> 00:08:36,310
For example if the user has a camera or not this package manager can have those values those data.

124
00:08:36,310 --> 00:08:47,290
And now I can say if package manager DOT has system feature package manager with capital P write package

125
00:08:47,290 --> 00:08:55,310
manager that Tamarod package manager that feature other like camera then open and close open and close

126
00:08:55,310 --> 00:09:00,360
this if statement by using the curly braces so this means if the device if the package manager that

127
00:09:00,430 --> 00:09:03,700
has system feature package manager that feature tramadol.

128
00:09:03,730 --> 00:09:08,250
If that device has actually a camera and B can access that camera right.

129
00:09:08,290 --> 00:09:15,110
If the camera is working properly and we can access it now I can say we need to create an intent for

130
00:09:15,110 --> 00:09:15,650
the camera.

131
00:09:15,650 --> 00:09:24,030
So here I can say intent and the name of this entity is going to be camera intent assignment operator

132
00:09:24,210 --> 00:09:38,000
new new intent an inside Apprentice's I can't say Medhi us or that action image capture because we want

133
00:09:38,000 --> 00:09:43,750
to actually allow the user to access the camera and take a picture.

134
00:09:43,770 --> 00:09:50,460
We want this intense media store that actual image capture we are creating an instant specific for that.

135
00:09:50,510 --> 00:09:52,310
So let's put a semicolon here.

136
00:09:52,310 --> 00:09:54,980
So it's going to access the camera application right.

137
00:09:55,460 --> 00:09:59,380
And here I can say start activity for result.

138
00:09:59,390 --> 00:10:06,530
So because we want to get that image that is actually captured by the user by using the camera we need

139
00:10:06,530 --> 00:10:09,570
to use this method start activity for result.

140
00:10:09,770 --> 00:10:12,830
So as you can see this and if it needs two arguments the first one is the intent.

141
00:10:12,830 --> 00:10:18,850
So if you have the intent the camera intent come up the next argument is going to be that requires the

142
00:10:18,870 --> 00:10:24,390
court which is very important because by using this request code you are accessing the camera.

143
00:10:24,410 --> 00:10:24,690
Right.

144
00:10:24,710 --> 00:10:25,730
And we're getting that picture.

145
00:10:25,730 --> 00:10:31,230
And later when we want to get that picture and put it on our image view we must use that request court

146
00:10:31,250 --> 00:10:33,350
in order to identify that image.

147
00:10:33,350 --> 00:10:34,700
This is very important.

148
00:10:34,700 --> 00:10:38,780
So let's provide and our request let's actually scroll to the top.

149
00:10:38,780 --> 00:10:48,350
And inside this class after declaring these variables I can actually say a private or private static

150
00:10:49,160 --> 00:10:57,220
final INT and here I can say let's actually capitalize it like this is actually our constant.

151
00:10:57,230 --> 00:11:02,690
So it's a convention in dhaba to capitalize are constant names.

152
00:11:02,690 --> 00:11:14,990
So I can't say camera camera underly image underline request request code underline quote.

153
00:11:15,090 --> 00:11:15,680
Right.

154
00:11:15,790 --> 00:11:18,130
Assignment operator let's assign a unique value.

155
00:11:18,130 --> 00:11:18,970
This is very important.

156
00:11:18,980 --> 00:11:23,530
We must assign a unique value a unique integer value to this constant.

157
00:11:23,530 --> 00:11:25,950
So 1000 is unique here right.

158
00:11:25,960 --> 00:11:33,660
Let's scroll down here and now for the second argument of the Smurfette I can say camera image request

159
00:11:33,670 --> 00:11:34,230
the.

160
00:11:34,360 --> 00:11:35,650
That's it.

161
00:11:35,650 --> 00:11:42,680
So now that we have this statements so it is this statement says if the device has a camera or not.

162
00:11:42,790 --> 00:11:47,550
If this device has a camera then it's going to actually create an intent for the camera.

163
00:11:47,770 --> 00:11:51,410
It's going to actually allow the user to access the camera application and take a picture.

164
00:11:51,820 --> 00:11:57,660
And then if you have the Smurfette in order to open the activity the camera activity actually the camera

165
00:11:57,670 --> 00:12:00,970
intent and the and we pass this request card right.

166
00:12:01,150 --> 00:12:06,320
So what happens if the user if the user's device doesn't have a camera.

167
00:12:06,490 --> 00:12:08,590
We need to check for that condition too.

168
00:12:08,740 --> 00:12:16,860
So after the end increase the price of this statement I can actually create an ill statement so as that

169
00:12:16,900 --> 00:12:20,230
I just need to open and close this statement by using these curly braces.

170
00:12:20,230 --> 00:12:29,110
And here I can say toast does make text first we need to pass the context my activity that this comma.

171
00:12:29,320 --> 00:12:33,010
And for the sake of argument we need to pass the value that you want to show to the use that and here

172
00:12:33,010 --> 00:12:34,950
I can see your device.

173
00:12:36,680 --> 00:12:47,920
Does not have a camera does not have a camera write and here I just need to put a comma and then I just

174
00:12:47,920 --> 00:12:50,920
need to specify the duration of the message that I want to show to the.

175
00:12:50,920 --> 00:12:53,970
So it is going to be lenth short.

176
00:12:54,400 --> 00:12:56,680
And then that show.

177
00:12:57,120 --> 00:13:02,290
So you're already familiar with the syntax of actually showing a toast to the user.

178
00:13:02,290 --> 00:13:09,380
So now that we have these quotes here let's run the application and let's see what happens.

179
00:13:09,440 --> 00:13:11,260
Let me actually run the application now.

180
00:13:11,530 --> 00:13:14,160
So here you can see that our application is running.

181
00:13:14,470 --> 00:13:15,300
Right.

182
00:13:15,460 --> 00:13:17,050
And I'm going to get you to click on this.

183
00:13:17,080 --> 00:13:19,040
Take a picture button let's click on it.

184
00:13:19,390 --> 00:13:24,220
Now as you can see it's going I should ask their permission is going to ask us that this application

185
00:13:24,610 --> 00:13:29,130
is going to access the camera do you want to allow this app to access the camera.

186
00:13:29,200 --> 00:13:33,460
So here if I click on it now it's going to allow me to access the camera but I just need to click on

187
00:13:33,460 --> 00:13:34,620
it again take a picture.

188
00:13:34,630 --> 00:13:37,780
Now you can see that the camera app is actually open.

189
00:13:37,810 --> 00:13:39,980
And we can access the camera of the application.

190
00:13:40,090 --> 00:13:43,270
So we created an instant for this camera here.

191
00:13:43,330 --> 00:13:44,290
Right.

192
00:13:44,290 --> 00:13:49,990
And we call it the Start activity for results so it's going to open this activity for us and we passed

193
00:13:49,990 --> 00:13:50,760
the camera intent.

194
00:13:50,770 --> 00:13:53,350
And this is our request that we're going to use it later.

195
00:13:53,350 --> 00:13:55,290
Well we want to get this picture.

196
00:13:55,300 --> 00:13:59,160
So for example this is actually emulated right is not the real camera.

197
00:13:59,320 --> 00:14:00,710
This is actually an emulated terminal.

198
00:14:00,710 --> 00:14:03,360
So let's actually take the picture here.

199
00:14:03,400 --> 00:14:05,290
So another picture is taken.

200
00:14:05,320 --> 00:14:06,800
Now if I click on this.

201
00:14:06,820 --> 00:14:15,920
I can hear in order to actually accept this image you can see that nothing happened right.

202
00:14:15,990 --> 00:14:21,740
All you want that takes an image to appear here in place of this image inside this image.

203
00:14:21,830 --> 00:14:25,910
Because image view is a shell that holds the actual image.

204
00:14:26,060 --> 00:14:33,030
So you want this image you now hold that image that I have taken by using that camera.

205
00:14:33,380 --> 00:14:38,560
So how we can do that we need to overwrite this thot activity for results.

206
00:14:38,600 --> 00:14:43,030
And we need to actually provide an implementation for this method.

207
00:14:43,070 --> 00:14:52,160
So now let's actually scroll down here and you can see that we have these curly braces that are related

208
00:14:52,160 --> 00:14:53,380
to the cleanup effort.

209
00:14:53,390 --> 00:15:01,850
So after the curly brace of this method and before the end in curly brace of this main activity class

210
00:15:02,210 --> 00:15:08,610
I'm going to just step in here on activity resolved just typing here on activity and the autocomplete

211
00:15:08,660 --> 00:15:13,840
feature of Android studio is going to help you to just dismiss it on activity results or just a person

212
00:15:13,850 --> 00:15:15,000
until Chanute keyboard.

213
00:15:15,320 --> 00:15:17,280
So you can see this if it is actually protected.

214
00:15:17,300 --> 00:15:24,330
Protected means that only the subclasses of that of the activity class can actually use this method.

215
00:15:24,710 --> 00:15:27,730
So our main activity class is a subclass of activity.

216
00:15:27,740 --> 00:15:28,250
Right.

217
00:15:28,490 --> 00:15:32,880
So we can actually override this method on activity result we can see these arguments.

218
00:15:32,890 --> 00:15:39,010
Request code which I talk to you we talked about it previously in this story.

219
00:15:39,440 --> 00:15:42,550
We have the result code and we have the data.

220
00:15:42,620 --> 00:15:46,240
So now it is actually calling to support that an activity result here.

221
00:15:46,250 --> 00:15:49,220
This method is must be called after this line of code.

222
00:15:49,430 --> 00:15:57,670
Here I can say if we have this request code right so here I can see if request code is actually the

223
00:15:57,670 --> 00:16:05,140
same as the request code that was sent to the camera or intent here like camera image request code.

224
00:16:05,230 --> 00:16:13,690
So here I can say if request call is a call to camera with tropicals see camera image request code right.

225
00:16:13,730 --> 00:16:19,840
And we have this result here we want to check that if the intent is actually opened normally and we

226
00:16:19,840 --> 00:16:21,860
have no problems.

227
00:16:21,900 --> 00:16:24,620
So here I can just type in results code.

228
00:16:24,630 --> 00:16:28,150
This is very important that you refer to this result called another request card.

229
00:16:28,170 --> 00:16:28,930
OK.

230
00:16:28,980 --> 00:16:31,140
Is equal to result.

231
00:16:31,170 --> 00:16:31,860
OK.

232
00:16:32,070 --> 00:16:36,880
So here we are checking that everything is fine and nothing goes wrong here.

233
00:16:36,900 --> 00:16:37,390
Right.

234
00:16:37,440 --> 00:16:40,540
Let's go inside the curly curly braces of this statement.

235
00:16:40,830 --> 00:16:41,450
OK.

236
00:16:41,460 --> 00:16:45,880
And here first of all we need to get the bundle right.

237
00:16:46,140 --> 00:16:50,940
So bundle is going to be actually given to us by the state.

238
00:16:51,450 --> 00:16:53,780
You can see this data because of the intent.

239
00:16:53,940 --> 00:16:56,770
We received this data from an activity result.

240
00:16:56,820 --> 00:16:57,330
Right.

241
00:16:57,330 --> 00:17:03,080
So first of all let me tell you that when this activity resolved if it is going to be caught.

242
00:17:03,090 --> 00:17:07,730
So after this superdad and on activity result you're going to create a toast message.

243
00:17:07,730 --> 00:17:14,040
So here I can say toast that makes text first I need to pass the context which is going to be main activity

244
00:17:14,040 --> 00:17:21,370
that this write come up and really to pass the message so the message is going to be an activity a result

245
00:17:21,460 --> 00:17:23,570
on activity result.

246
00:17:24,780 --> 00:17:34,000
Is called right is called and I put a comma here and then I need to specify that actually the duration

247
00:17:34,180 --> 00:17:38,850
so length short that show.

248
00:17:38,890 --> 00:17:44,500
So let's run the application because I want to show you then decide if it is called Ventas an activity

249
00:17:44,500 --> 00:17:46,240
result is actually caught.

250
00:17:46,270 --> 00:17:48,640
Let me show you the emulator.

251
00:17:48,640 --> 00:17:51,110
So not our application is running on the simulator right.

252
00:17:51,310 --> 00:17:53,030
Let's click on take a picture.

253
00:17:53,320 --> 00:17:54,980
Let's take a picture now.

254
00:17:55,000 --> 00:17:59,410
And this really can accept as you can see it says unactivated result is called.

255
00:17:59,650 --> 00:18:05,560
So the unexpected result is called When we take a picture and we actually accept that.

256
00:18:05,560 --> 00:18:13,700
Now we can see that here when we back to this main activity here an activity result is called.

257
00:18:13,990 --> 00:18:20,590
So here is the place this non-activity result is actually is the place where we want to actually put

258
00:18:20,590 --> 00:18:26,560
that image that is taken by the user by using the camera of the device and put that image here inside

259
00:18:26,560 --> 00:18:28,330
this image view.

260
00:18:28,330 --> 00:18:32,520
So let's go back to our I should imagine if the glass inside is an activity result.

261
00:18:32,530 --> 00:18:38,020
So now we have this statement inside this if statement is the place to get that picture how we can get

262
00:18:38,020 --> 00:18:38,750
that picture.

263
00:18:38,800 --> 00:18:41,440
First we need to create of the level of the bundle.

264
00:18:41,560 --> 00:18:45,380
So bundle the name of our idea but it's going to be bundled assignment operator.

265
00:18:45,670 --> 00:18:48,690
So we have these data arguments right which is the intent.

266
00:18:48,730 --> 00:18:52,920
The intent is the intent of the camera intent actually right.

267
00:18:52,960 --> 00:18:58,180
So I can't say data that gets X through us semi-colon.

268
00:18:58,450 --> 00:19:03,940
So by using this to get extra Smurfette on this data which is of type intent you are going to access

269
00:19:04,160 --> 00:19:08,070
the data that is inside that intent to actually image.

270
00:19:08,080 --> 00:19:09,240
Right.

271
00:19:09,250 --> 00:19:13,060
So this intent which is its name is data right.

272
00:19:13,060 --> 00:19:19,510
These data holds that image that is taken by the user by calling this a good extra Asmaa if it does

273
00:19:19,660 --> 00:19:25,080
get stressed if it is going to return a bundle the return type of this method his bundle.

274
00:19:25,090 --> 00:19:30,610
And we can't assign the return type of this value that returns value of the Smurfette to this variable

275
00:19:30,610 --> 00:19:31,050
bundle.

276
00:19:31,060 --> 00:19:33,320
Let me show you the Android documentation.

277
00:19:33,880 --> 00:19:36,100
So here it is the android documentation right.

278
00:19:36,370 --> 00:19:41,880
And I actually searched for the intense class list inside the first part the sense for Internet and

279
00:19:41,960 --> 00:19:46,040
that app that intent on Android that content that the Internet actually.

280
00:19:46,050 --> 00:19:46,560
Right.

281
00:19:46,570 --> 00:19:51,550
So just like this one here and here let's search for the get extra effort.

282
00:19:51,550 --> 00:19:57,830
So in order to search for a specific Meffert in Andhra it's documentation if you are using a match point

283
00:19:57,840 --> 00:20:02,500
six you just need to hold down to the comments on your keyboard and the person that that key on your

284
00:20:02,500 --> 00:20:02,860
keyboard.

285
00:20:02,890 --> 00:20:05,250
And then just search for that specific method.

286
00:20:05,470 --> 00:20:10,120
If you are using of Indos machine you just need to hold down the control on your keyboard and then press

287
00:20:10,120 --> 00:20:13,750
on if your new keyboard in order to search for a specific effect.

288
00:20:13,750 --> 00:20:19,040
So here we are searching for the get extra MFL we can see that the return type of this for this bundle.

289
00:20:19,090 --> 00:20:26,080
And it says retrieves our map of extended data from the intent of map of extent that data up means it

290
00:20:26,080 --> 00:20:30,320
is going to be key value right map meaning key value here.

291
00:20:30,400 --> 00:20:30,890
Right.

292
00:20:30,950 --> 00:20:37,900
And it means that it's going to give us our map a key value of extended data from the Internet.

293
00:20:38,110 --> 00:20:43,270
So this get through as Meffert the return value the bundle doesn't throw anything about image or bitmap

294
00:20:43,880 --> 00:20:44,860
right.

295
00:20:44,950 --> 00:20:51,880
So we need to actually create a variable of type bitmap inside our main activity class and we can actually

296
00:20:51,880 --> 00:20:55,370
initialize our bitmap by using this map here.

297
00:20:55,780 --> 00:20:59,080
That is going to be returned from the get extra Smurfette.

298
00:20:59,230 --> 00:21:02,660
Let's go to the main activity class here.

299
00:21:02,760 --> 00:21:09,370
Now let's go let's scroll to the top and inside this class after this line of code that actually specifies

300
00:21:09,730 --> 00:21:16,340
the Chambre image Scott I can create a valuable private bitmap which is of the people with my right.

301
00:21:16,360 --> 00:21:18,300
The name is bitmapped semicolon.

302
00:21:18,520 --> 00:21:18,790
Right.

303
00:21:18,790 --> 00:21:21,230
I didn't initialize it I just declared this value.

304
00:21:21,250 --> 00:21:24,930
But let's scroll down here and let's go inside these unactivated result.

305
00:21:25,030 --> 00:21:33,490
Inside this if statement after getting the bundle here from the stator I can actually just initialize

306
00:21:33,550 --> 00:21:37,650
the bitmap how I can refer to this bitmap variable assignment operator.

307
00:21:37,930 --> 00:21:43,230
So I told you that the GET throws method doesn't know anything about bitmap or images.

308
00:21:43,410 --> 00:21:51,070
So you are 100 percent sure that there is actually a bitmap so remember that the image that is taken

309
00:21:51,070 --> 00:21:55,350
by the user by using the camera is actually going to be of type bitmap.

310
00:21:55,750 --> 00:21:58,530
So let's cast it to bitmap here.

311
00:21:59,000 --> 00:22:01,380
OK bitmap.

312
00:22:01,910 --> 00:22:09,940
And after this practice this year after this casting here I can refer to this bundle data just by using

313
00:22:09,940 --> 00:22:16,290
this gets Meffert on this bundle you're going to get the value by passing the key.

314
00:22:16,540 --> 00:22:18,900
So bypassing the key are going to get the value.

315
00:22:18,940 --> 00:22:21,630
So that's why it is called map right.

316
00:22:21,700 --> 00:22:25,380
Key value so get is going to be called on the.

317
00:22:25,720 --> 00:22:26,670
And bypassing.

318
00:22:26,710 --> 00:22:28,050
You can see that it says Key.

319
00:22:28,060 --> 00:22:28,570
Right.

320
00:22:28,570 --> 00:22:30,630
The pass the key is going to give us the value.

321
00:22:30,640 --> 00:22:32,850
So said this actually to send it like this Meffert.

322
00:22:33,010 --> 00:22:36,580
You can see that the arguments that we need to pass through this method is going to be off the screen

323
00:22:36,640 --> 00:22:37,460
and its name is key.

324
00:22:37,510 --> 00:22:38,900
So just put two coats here.

325
00:22:38,950 --> 00:22:42,010
The key is going to be data right.

326
00:22:42,250 --> 00:22:48,090
When the past Key data is going to give us the value it is going to be off the bitmap but that gets

327
00:22:48,090 --> 00:22:50,990
me if it doesn't know anything about the bitmap.

328
00:22:51,100 --> 00:22:57,220
But you are 100 percent sure it is going to be off the map so it just casts that two bitmap object and

329
00:22:57,250 --> 00:22:59,370
we initialized our bitmap area.

330
00:22:59,590 --> 00:23:07,200
Now after this line of code I can see IMT photo that set image bitmap bitmap.

331
00:23:07,440 --> 00:23:08,200
That's it.

332
00:23:08,230 --> 00:23:10,240
Let's run that application now.

333
00:23:10,630 --> 00:23:13,590
So here you can see that our application is running on the simulator.

334
00:23:13,720 --> 00:23:15,190
Let's take a picture.

335
00:23:17,520 --> 00:23:22,020
Let's accept it's now you can see this image here.

336
00:23:22,020 --> 00:23:22,290
Right.

337
00:23:22,300 --> 00:23:23,710
An activity is all it is called.

338
00:23:23,740 --> 00:23:27,770
And here the image is actually put inside this image of you.

339
00:23:27,880 --> 00:23:28,630
That's it.

340
00:23:28,630 --> 00:23:31,560
If you want to can test this up on your actual device.

341
00:23:31,930 --> 00:23:38,530
So now in the next tutorial we're going to actually add another class in order to allow the user to

342
00:23:38,530 --> 00:23:45,430
use these search parties in order to colorful in order to make his image and truly colorful and add

343
00:23:45,460 --> 00:23:46,910
colors to this image.

344
00:23:47,020 --> 00:23:50,500
Red green and blue.

345
00:23:50,560 --> 00:23:53,560
So let's see how we can do that in the next story or so.

346
00:23:53,800 --> 00:23:54,780
Thank you very much for watching.

347
00:23:54,790 --> 00:23:59,690
If you have any questions about the concepts that I taught you so far please post the discussion in

348
00:23:59,690 --> 00:24:02,770
the course and then I do my best to answer all of your questions.

