1
00:00:01,100 --> 00:00:06,590
In this video, you are going to learn how to request for permissions, and we're going to look at how

2
00:00:06,590 --> 00:00:11,030
to request for one permission, for example, for the camera permission so that we can use the camera

3
00:00:11,030 --> 00:00:12,110
in our application.

4
00:00:12,260 --> 00:00:16,700
But we're also going to look at how we can ask for multiple permissions at once, which means, for

5
00:00:16,700 --> 00:00:20,360
example, the location also and not just a camera permission.

6
00:00:20,630 --> 00:00:24,090
So you see here, I can now give access to one thing.

7
00:00:24,110 --> 00:00:30,020
So, for example, for the camera and then also it will ask me for the permission for the location and

8
00:00:30,020 --> 00:00:33,710
here can say what kind of location I want to give the application.

9
00:00:33,710 --> 00:00:37,070
So the precise location or an approximate location.

10
00:00:37,340 --> 00:00:42,260
So this will really depend on the kind of app you want to build.

11
00:00:42,530 --> 00:00:48,080
But I'm just going to give the approximate location, for example, and I'm just going to give it access

12
00:00:48,080 --> 00:00:49,010
while I'm using the app.

13
00:00:49,310 --> 00:00:54,910
So you see permission was denied for location because I didn't give the location like the final location

14
00:00:54,920 --> 00:00:58,790
of precise location, but I did give the course location.

15
00:00:59,090 --> 00:01:02,150
And you're going to see why that is and how we can set all of that up.

16
00:01:02,420 --> 00:01:06,400
So let's go ahead and look into the project that I prepared here.

17
00:01:06,410 --> 00:01:12,320
So I have this activity main XM L, which just has this one button in there, which just says request

18
00:01:12,320 --> 00:01:13,100
camera permission.

19
00:01:13,100 --> 00:01:18,230
So if you don't know what's up here, you should definitely jump into another lecture of mine where

20
00:01:18,230 --> 00:01:19,820
you learn about XML basics.

21
00:01:20,030 --> 00:01:24,620
So here we request for the camera permission and now inside of our main activity.

22
00:01:24,620 --> 00:01:29,840
That's where we are going to request for the camera permission and for the other permissions also.

23
00:01:30,110 --> 00:01:36,560
And in order to even be able to request for any of the permissions, I need to define that in the Android

24
00:01:36,560 --> 00:01:37,160
Manifest.

25
00:01:37,160 --> 00:01:43,130
So there is this Manifest folder and there's this Android Manifest, some L file and in there you can

26
00:01:43,700 --> 00:01:48,200
on one hand, of course, have all of your activities and defined settings for your application and

27
00:01:48,200 --> 00:01:49,520
activities and stuff.

28
00:01:49,850 --> 00:01:54,730
But what's more important for this video is going to be the permissions that we want to use.

29
00:01:54,740 --> 00:01:59,450
So here you need to create this tag user's permission with the Android name and then the permission

30
00:01:59,450 --> 00:02:05,580
that you want to use in the application, or that you will require for the application to work properly.

31
00:02:05,600 --> 00:02:08,509
For example, I'm adding the camera permission here at this point.

32
00:02:08,960 --> 00:02:13,940
So this is the absolute basis, otherwise the rest of the court will not work properly.

33
00:02:14,270 --> 00:02:17,120
So it's really important that you set that up in your manifest.

34
00:02:17,540 --> 00:02:25,510
So let's first just ask for the camera permission, and therefore I will require something called a

35
00:02:25,580 --> 00:02:26,960
activity result launcher.

36
00:02:27,170 --> 00:02:33,740
So I'm going to create a new global variable, which I'm going to call camera result launcher, and

37
00:02:33,830 --> 00:02:36,980
it will be of type activity result launcher.

38
00:02:37,670 --> 00:02:41,060
So you see you need to parse what kind of launcher it will be.

39
00:02:41,180 --> 00:02:43,430
Well, will be passing test by a string.

40
00:02:43,880 --> 00:02:53,570
So now we can define this here directly, and I'm going to register for an activity result like so and

41
00:02:53,570 --> 00:02:56,780
here I can pass the activity result contracts.

42
00:02:58,140 --> 00:03:04,860
Like so activity result contracts, plural, where I then request for permission.

43
00:03:05,700 --> 00:03:11,190
And here at this point, I can now say whether it's granted or not.

44
00:03:11,460 --> 00:03:17,730
So here we're passing the register for activity result, which will return an activity result launcher.

45
00:03:18,210 --> 00:03:22,500
So we can now say if it's granted, so is granted.

46
00:03:24,060 --> 00:03:27,570
Well, based on what we get there, we can now work with it.

47
00:03:27,780 --> 00:03:30,140
And by the way, this is a little confusing here.

48
00:03:30,150 --> 00:03:33,450
We need to make sure that we have the closing bracket up there.

49
00:03:33,780 --> 00:03:40,380
OK, so we're calling this register for activity result and we are passing the activity result contracts

50
00:03:40,380 --> 00:03:47,430
request permission method, which we then use a lambda here where we know whether the permission was

51
00:03:47,430 --> 00:03:48,450
granted or not.

52
00:03:48,660 --> 00:03:51,360
So this is just a form which you need to follow here.

53
00:03:51,870 --> 00:03:52,170
All right.

54
00:03:52,170 --> 00:03:54,990
So if it's granted, I cannot go ahead and check.

55
00:03:55,350 --> 00:04:04,300
So if granted or is granted the precise here, then I can go ahead and display those.

56
00:04:04,320 --> 00:04:07,410
So I'm just going to display this toast saying, Hey.

57
00:04:07,920 --> 00:04:08,820
Permission granted?

58
00:04:09,870 --> 00:04:10,880
OK, very simple.

59
00:04:10,890 --> 00:04:12,570
Let's import toast here as well.

60
00:04:13,230 --> 00:04:13,410
OK.

61
00:04:13,440 --> 00:04:17,519
Permission was granted, and otherwise I know that permission wasn't granted.

62
00:04:17,850 --> 00:04:21,029
So here, permission denied for camera.

63
00:04:22,370 --> 00:04:29,000
OK, so this is our camera result launcher, this is how it works for one particular permission that

64
00:04:29,000 --> 00:04:30,440
you can ask for.

65
00:04:30,860 --> 00:04:37,880
And now inside of our own create, we actually need to launch this thing right in order to launch the

66
00:04:37,880 --> 00:04:38,270
thing.

67
00:04:38,630 --> 00:04:41,150
What I'm going to require is going to be my button.

68
00:04:41,180 --> 00:04:43,310
OK, so here in my activity may smell.

69
00:04:43,580 --> 00:04:46,670
I have this button with an ID of button camera permission.

70
00:04:46,910 --> 00:04:49,160
So let me find it by outside.

71
00:04:49,250 --> 00:04:50,620
I'm not going to use vue binding here.

72
00:04:50,630 --> 00:04:51,920
I'm going to keep it super simple.

73
00:04:52,250 --> 00:04:59,240
So here will button camera permission will be a button.

74
00:05:00,700 --> 00:05:02,740
And I will find it by its side.

75
00:05:04,060 --> 00:05:10,660
Like so and I thought I'd start button camera permission, so this will be a photo button, so I need

76
00:05:10,660 --> 00:05:11,530
to import button.

77
00:05:11,890 --> 00:05:17,230
So now I have the button and I can use the button camera permission.

78
00:05:17,560 --> 00:05:17,980
Set on.

79
00:05:17,980 --> 00:05:18,910
Click Listen there here.

80
00:05:19,630 --> 00:05:22,300
In order to say what should happen once we click on the button.

81
00:05:23,230 --> 00:05:28,780
So what I'm going to do is I'm going to check for the version that we are running here because if I'm

82
00:05:28,780 --> 00:05:34,090
using an older Android version, I want to treat this thing differently.

83
00:05:34,150 --> 00:05:38,080
So here, version SDK underscore it.

84
00:05:38,170 --> 00:05:41,470
So I'm checking for the Android version that somebody is using.

85
00:05:42,740 --> 00:05:43,430
With their phone.

86
00:05:45,120 --> 00:05:52,530
And you're comparing it to be built short version coats and coats thought.

87
00:05:53,610 --> 00:06:03,150
So if you're using Android M or newer, then run the code that I'm going to run because I'm not going

88
00:06:03,150 --> 00:06:08,880
to run this permission code for all the versions that you would need to run different kinds of request

89
00:06:08,880 --> 00:06:09,140
code.

90
00:06:09,450 --> 00:06:10,620
But usually this would be fine.

91
00:06:10,890 --> 00:06:14,820
So we're just double checking whether we're really using a phone that has at least Android.

92
00:06:14,820 --> 00:06:20,940
And I think Android and was something like 4.1 or whatever, like super old version and here.

93
00:06:22,010 --> 00:06:27,830
We also need to check if should show request permission, Russia, Neal, is.

94
00:06:29,200 --> 00:06:35,380
True for our particular manifest that we're more manifest of permission, that we're looking at the

95
00:06:35,380 --> 00:06:36,010
camera.

96
00:06:36,940 --> 00:06:42,010
OK, so here permission and you see manifest was fine, but permission is not fine.

97
00:06:42,310 --> 00:06:46,810
And that has to do with the permission that was automatically added being the wrong permission import.

98
00:06:47,140 --> 00:06:51,370
So by default, Android Studio thinks it's a good idea to add this manifest.

99
00:06:51,910 --> 00:06:54,100
But actually, we need to use the other one.

100
00:06:54,100 --> 00:06:58,450
So delete at entry and go to import and then select the Android version here.

101
00:06:58,720 --> 00:07:03,730
So you will see that now it's going to be this Android manifest.

102
00:07:03,910 --> 00:07:10,360
So import Android Manifest and now we can actually do a check here.

103
00:07:11,460 --> 00:07:14,970
Or actually run the code that we want to run.

104
00:07:15,390 --> 00:07:18,540
So I'm checking whether I want or what I should show.

105
00:07:18,570 --> 00:07:21,570
Request permission rationale, which means.

106
00:07:22,740 --> 00:07:29,730
That if, for example, the application does not have access to the permission, then it should show

107
00:07:29,730 --> 00:07:37,920
why it should use this application, and I'm going to create a little alert dialog here, and this alert

108
00:07:37,920 --> 00:07:44,610
dialog will basically just display that I want to have access to a permission or the application won't

109
00:07:44,610 --> 00:07:45,240
work properly.

110
00:07:45,480 --> 00:07:52,140
So this will just be a method that we're using here, that we create where we have a title that we pass

111
00:07:52,140 --> 00:07:53,280
and the message that we pass.

112
00:07:53,280 --> 00:08:00,840
And then we create an alert dialog using a builder and this builder will reset the title, the message,

113
00:08:01,110 --> 00:08:04,890
as well as the positive button, in this case, just a cancel button.

114
00:08:05,070 --> 00:08:11,520
And what should happen once this button is clicked and we're just saying this miss should be executed.

115
00:08:11,520 --> 00:08:16,860
So we're just saying, OK, if the user presses on this cancel button, then this Mr. dialog and of

116
00:08:16,860 --> 00:08:19,170
course, we need to create this dialogue as well.

117
00:08:19,170 --> 00:08:19,800
Let's show it.

118
00:08:20,010 --> 00:08:24,120
So that's what this so rational dialogue method will do for us.

119
00:08:24,930 --> 00:08:33,870
So here what I'm just going to say is that I would like to show the Russia-NATO dialog with a little

120
00:08:34,740 --> 00:08:36,299
title as well as a message.

121
00:08:36,299 --> 00:08:37,650
So let me put that in here.

122
00:08:37,950 --> 00:08:42,090
So the the title should be permission demo request, camera access, and the message should be camera

123
00:08:42,090 --> 00:08:45,390
cannot be used because camera access is denied.

124
00:08:45,840 --> 00:08:50,340
So this is something that I want to display to the user as a little dialogue if I'm trying to access

125
00:08:50,340 --> 00:08:52,710
the camera feature and it just doesn't work.

126
00:08:53,460 --> 00:08:56,760
OK, so now if that's not the case?

127
00:09:02,240 --> 00:09:09,680
And I should not show the rationale, then I'm going to launch for the camera result.

128
00:09:10,010 --> 00:09:18,770
So camera result, launcher launch with the permission that I'm looking at so many first thought permission

129
00:09:18,770 --> 00:09:20,030
dot camera.

130
00:09:21,530 --> 00:09:26,820
OK, so at this point, we can test our application because in the uncreated, now we have this button,

131
00:09:26,840 --> 00:09:32,840
once we click on the button, we request for permission for the camera permission in particular.

132
00:09:33,470 --> 00:09:36,200
So let's run the application and click on the button.

133
00:09:36,200 --> 00:09:41,480
You see the permission request comes up and let's not allow it.

134
00:09:42,080 --> 00:09:43,910
And you see permission denied for camera.

135
00:09:44,240 --> 00:09:46,190
Now let us request for camera permission.

136
00:09:46,230 --> 00:09:48,680
You see permission demo requires camera access.

137
00:09:48,680 --> 00:09:51,140
Camera cannot be used because camera access denied.

138
00:09:52,280 --> 00:09:57,980
OK, so basically, this condition here is met, which is why the rationale dialogue is being displayed

139
00:09:58,250 --> 00:09:59,390
because we don't have access.

140
00:09:59,690 --> 00:10:05,930
So you were just checking that we have not access, so to speak, and if we don't not have access,

141
00:10:05,930 --> 00:10:13,100
so to speak, or we weren't denied before, then we run into this block where we say, OK, then please

142
00:10:13,100 --> 00:10:14,240
ask for permission.

143
00:10:15,020 --> 00:10:17,120
OK, so this is where we're doing it.

144
00:10:17,360 --> 00:10:24,860
And then accordingly, you would, of course, launched a camera then if you have the right to use the

145
00:10:24,860 --> 00:10:25,580
application.

146
00:10:26,390 --> 00:10:31,730
OK, so here camera result launcher, which is this camera result launcher that we created.

147
00:10:32,450 --> 00:10:37,220
So now unfortunately, I will not have access to the camera permission.

148
00:10:37,490 --> 00:10:41,270
So how can I manage dead while I can go to my settings?

149
00:10:42,030 --> 00:10:44,300
And let me just go to the app settings?

150
00:10:45,760 --> 00:10:53,110
Here, settings and search for permission, and then you can go for camera permission controller and

151
00:10:53,110 --> 00:10:57,070
search for the permission demo here and allow only by using the app, for example.

152
00:10:57,760 --> 00:11:04,510
OK, so now if I go to my permission request, you see permission granted for camera.

153
00:11:04,810 --> 00:11:07,300
So now I granted it outside of the application.

154
00:11:07,540 --> 00:11:13,000
Of course, I could have alternatively just deleted this permission and let me see if that's the right

155
00:11:13,000 --> 00:11:13,180
one.

156
00:11:13,180 --> 00:11:14,080
I'm going to delete both.

157
00:11:14,800 --> 00:11:18,070
So the one that I had prepared, as well as the one we just built.

158
00:11:18,730 --> 00:11:20,230
So here app info.

159
00:11:21,330 --> 00:11:26,250
Uninstall and then reinstall by rerunning.

160
00:11:27,250 --> 00:11:29,140
I now request for permission.

161
00:11:29,260 --> 00:11:30,880
And now this time we are going to allow it.

162
00:11:31,030 --> 00:11:32,350
Permission granted for camera.

163
00:11:32,740 --> 00:11:35,320
OK, so you see this, are you contested?

164
00:11:35,320 --> 00:11:43,090
But basically at this point, I can use the camera functionality of Android and use it in order to,

165
00:11:43,240 --> 00:11:48,970
well, get an activity for result and get the image back that the user has to take in, for example,

166
00:11:48,970 --> 00:11:49,690
with the camera.

167
00:11:50,800 --> 00:11:53,860
So that's how we can ask for one particular permission.

168
00:11:54,160 --> 00:12:00,160
And just quickly about this permission rationale here, the system automatically checks if the permission

169
00:12:00,160 --> 00:12:00,940
exists, right?

170
00:12:01,240 --> 00:12:06,400
And if that's has been denied, this would be activated to show the educational message about your app

171
00:12:06,400 --> 00:12:12,700
explaining why the permission is needed, and I recommend it as the right way to check for permission.

172
00:12:12,940 --> 00:12:17,710
So if permission has not been requested before, then this code here will be executed.

173
00:12:18,220 --> 00:12:21,910
OK, so now let's see how we can ask for multiple permissions.

174
00:12:22,150 --> 00:12:25,780
Therefore, we need to make a change to this part here.

175
00:12:26,020 --> 00:12:31,930
Actually, let me reduce it to the smaller part here and just duplicate it.

176
00:12:32,350 --> 00:12:36,970
And instead, I'm going to use camera and location result launcher.

177
00:12:37,300 --> 00:12:40,990
So this will also be an activity result launcher.

178
00:12:40,990 --> 00:12:44,920
But this time it's not going to just have a string here, but an array of strings.

179
00:12:45,430 --> 00:12:55,330
So array of string and then accordingly, we need to make a change here as well because we are still

180
00:12:55,930 --> 00:12:59,920
registering for activity result, but we're not requesting for one permission.

181
00:12:59,920 --> 00:13:07,810
But we create we request for multiple permissions multiple and I need to close here with another arrow.

182
00:13:07,840 --> 00:13:08,650
I believe.

183
00:13:10,510 --> 00:13:11,140
Like so.

184
00:13:14,580 --> 00:13:16,350
And according to get rid of this arrow.

185
00:13:16,770 --> 00:13:20,250
So here we can now request for multiple permissions like so.

186
00:13:21,290 --> 00:13:27,680
But now things are changing, so we are asking for multiple permissions, and we're not we don't get

187
00:13:27,680 --> 00:13:29,150
is granted now.

188
00:13:29,420 --> 00:13:35,180
But what we do get is if we look at it, we get a mutable map.

189
00:13:35,960 --> 00:13:40,220
So it will be the mutable map now and we can get give it a name.

190
00:13:40,520 --> 00:13:42,710
And I'm going to call it permissions.

191
00:13:44,270 --> 00:13:53,840
OK, so based on the permissions that I am given now, I want to go through all of them with a for each

192
00:13:54,470 --> 00:13:54,830
loop.

193
00:13:55,730 --> 00:14:00,650
So here with this for each, I'm going to do it is well.

194
00:14:00,650 --> 00:14:06,350
Here I get another immutable map with a string and Boolean value, which is basically going to be while

195
00:14:06,350 --> 00:14:10,040
the string will be the key and the Boolean will be whether we have access or not.

196
00:14:10,400 --> 00:14:16,280
So the vault permission name will be it.

197
00:14:17,390 --> 00:14:22,160
But key so this it is this mutable map with a mutable entry.

198
00:14:22,650 --> 00:14:29,120
OK, so this will be the permission name and then we have this is granted, which will be its value.

199
00:14:29,930 --> 00:14:36,980
So these two values here, these two variables will now contain on one hand, what is the permission

200
00:14:36,980 --> 00:14:43,910
that we requested for, for example, the camera permission and this one will hold the value, whether

201
00:14:43,910 --> 00:14:45,740
we were granted this permission or not.

202
00:14:46,340 --> 00:14:56,120
So now we can check if is granted is true, then we check for the permission name because we don't know

203
00:14:56,120 --> 00:15:00,410
which permission was granted because it could be that we have the permission granted for the camera,

204
00:15:00,410 --> 00:15:05,840
but not for the location or for the location, but not for the camera or for both of them or for neither.

205
00:15:06,050 --> 00:15:07,640
So we have all of these different options.

206
00:15:08,330 --> 00:15:15,530
Options are limitless, so we can now go ahead and use the permission we can check if we have access

207
00:15:15,530 --> 00:15:16,790
to the final location.

208
00:15:17,450 --> 00:15:22,730
So we find location well because I also want to have the location of the user, right?

209
00:15:23,060 --> 00:15:30,740
And as I said earlier, if you want to get access to the location, you need to add to send what you

210
00:15:30,740 --> 00:15:34,220
need to add this permission in the Android Manifest file as well.

211
00:15:34,610 --> 00:15:38,150
So here I'm going to get access for fine location.

212
00:15:38,150 --> 00:15:39,020
I'm going to search for that.

213
00:15:39,410 --> 00:15:47,600
And then while you are using locations, you should also access the course location.

214
00:15:47,900 --> 00:15:56,600
So at this into your manifest as well, this is just something about locations, because if you don't

215
00:15:56,600 --> 00:16:02,090
get the exact location, you may be at least get a rough location, which will give you the exact course

216
00:16:02,090 --> 00:16:02,600
location.

217
00:16:03,260 --> 00:16:08,480
OK, so we're checking if the permission that was granted is the access fine location.

218
00:16:08,780 --> 00:16:17,120
If that's the case, then I'm just going to display a toast saying, hey, the permission was granted

219
00:16:17,120 --> 00:16:19,340
for the location and otherwise.

220
00:16:19,370 --> 00:16:25,550
So if it wasn't the permission that was to access fine location here, of course, I could also use

221
00:16:25,550 --> 00:16:29,000
an if statement and ask for the permission named specifically.

222
00:16:29,000 --> 00:16:33,650
Again, this would make sense if you're asking for multiple permissions here, and in this case, I

223
00:16:33,650 --> 00:16:36,110
do know that it will be the camera that was granted.

224
00:16:36,290 --> 00:16:39,950
OK, so it wasn't the access fine location that was granted.

225
00:16:39,950 --> 00:16:42,440
It will be the camera that was granted.

226
00:16:43,520 --> 00:16:45,920
Even though we have to be careful here, I will say what?

227
00:16:45,920 --> 00:16:46,850
Why in the seconds.

228
00:16:46,850 --> 00:16:49,040
But generally speaking, this is how it would work.

229
00:16:49,430 --> 00:16:56,900
So that's how it works for our if the permission name was to access fine location.

230
00:16:57,590 --> 00:17:04,160
So then if we are in the last block here and it's fine to open it, but I think it's more readable.

231
00:17:04,460 --> 00:17:05,660
So here we are.

232
00:17:05,660 --> 00:17:07,790
Inside of this block off is granted.

233
00:17:08,180 --> 00:17:15,170
So here, if it was not granted, then we know that the permission that we asked for was not granted

234
00:17:15,170 --> 00:17:16,819
and here we need to do the same check.

235
00:17:17,060 --> 00:17:22,339
So we check again for the fine location.

236
00:17:23,480 --> 00:17:30,770
And we know that we were denied the location as well as denied the camera.

237
00:17:30,800 --> 00:17:32,480
So in the health block?

238
00:17:32,880 --> 00:17:35,480
OK, so this is a for each loop, right?

239
00:17:35,720 --> 00:17:39,200
It goes through all the permissions that were granted or not granted.

240
00:17:39,560 --> 00:17:45,760
And but depending on whether it was granted, it will run into this if statement and if it was not granted,

241
00:17:45,760 --> 00:17:47,930
then we'll run into this statement.

242
00:17:48,350 --> 00:17:54,860
So it will run into this block with all of its beautiful statements were, in our case, just posts

243
00:17:54,860 --> 00:17:55,970
that we're going to use here.

244
00:17:58,550 --> 00:18:04,670
OK, so now, according to him, I will need to make a change to my aunt, click listener here.

245
00:18:05,270 --> 00:18:12,530
So instead of just using camera result launcher and launch it, I'm going to use my camera and location

246
00:18:12,530 --> 00:18:13,310
result launcher.

247
00:18:13,790 --> 00:18:20,270
And here I need to pass an array of permissions and not just one permission, so I can just go ahead

248
00:18:20,270 --> 00:18:23,450
and create an array of the permissions that I want to use.

249
00:18:23,780 --> 00:18:26,390
In my case, it will be the permission camera.

250
00:18:27,860 --> 00:18:30,200
And that's like this came up.

251
00:18:30,560 --> 00:18:33,560
Well, I need to write it manually, I guess.

252
00:18:33,920 --> 00:18:35,650
And then separate it with a comma.

253
00:18:35,660 --> 00:18:38,720
I add the second permission that I want to add here.

254
00:18:38,720 --> 00:18:46,130
So manifest dot permission, dot and excess fine location.

255
00:18:46,760 --> 00:18:49,760
OK, so these are going to be the two permissions that I'm asking for.

256
00:18:49,790 --> 00:18:54,890
You could, of course, add another one here and so forth, but I'm just going to go with two.

257
00:18:55,730 --> 00:18:56,210
OK.

258
00:18:56,750 --> 00:19:02,410
So at this point, we should be able to run it and ask for multiple permissions.

259
00:19:02,420 --> 00:19:08,690
But before I do that, let me uninstall the application real quick because I want to show you how it

260
00:19:08,690 --> 00:19:09,650
looks from scratch.

261
00:19:09,950 --> 00:19:12,470
OK, so now let's run the application.

262
00:19:14,890 --> 00:19:19,660
And request for permission to see it asks for the camera, so I'm going to say, OK, I'm going to give

263
00:19:19,660 --> 00:19:24,700
you the permission and then I'm going to give the precise permission while using the app and you see

264
00:19:24,700 --> 00:19:27,850
permission granted for location and then just a second later.

265
00:19:28,120 --> 00:19:29,470
Permission granted for camera.

266
00:19:30,410 --> 00:19:34,860
Now, if I run it again, it will just display those permission details.

267
00:19:34,930 --> 00:19:39,520
So now we know we have permission and we can go ahead and use those permissions in our application.

268
00:19:40,120 --> 00:19:45,690
So now the thing is that I could also run into this weird situation.

269
00:19:45,700 --> 00:19:54,130
I me show you where I uninstalled this application real quick uninstall and then run the application

270
00:19:54,130 --> 00:19:59,350
again, because here I'm accessing the fine location or checking for the find location.

271
00:19:59,350 --> 00:20:06,010
But what if I was given the course location and not the final location and the coarse location I will

272
00:20:06,010 --> 00:20:07,990
show you is actually this part here.

273
00:20:08,000 --> 00:20:10,300
This approximate, this is the course location.

274
00:20:10,540 --> 00:20:13,750
So this precise here's the final location and this one will be the course location.

275
00:20:13,750 --> 00:20:15,970
So let's select the approximate here.

276
00:20:16,330 --> 00:20:19,540
And then you say while using and you see permission denied for location.

277
00:20:19,840 --> 00:20:25,780
Even though we are well, we have access to the location, but not to define location, so we could

278
00:20:25,780 --> 00:20:26,640
be more precise.

279
00:20:26,650 --> 00:20:29,500
You're saying permission denied for fine location?

280
00:20:30,680 --> 00:20:30,960
OK.

281
00:20:31,040 --> 00:20:38,360
This LS, if could be the well, maybe a little challenge for you post the video and adjust this f block

282
00:20:38,360 --> 00:20:41,030
here for the coarse location as well.

283
00:20:42,680 --> 00:20:54,800
OK, so I hope you tried it, and I'm going to do it is I'm going to add the cause location here, the

284
00:20:54,800 --> 00:21:00,830
permission and this one will be denied for.

285
00:21:04,690 --> 00:21:06,360
Course location.

286
00:21:08,410 --> 00:21:10,870
And the ALS blog, it will just be the camera.

287
00:21:11,200 --> 00:21:11,680
OK.

288
00:21:12,680 --> 00:21:14,660
So here, camera.

289
00:21:16,860 --> 00:21:18,750
And then accordingly, we will need that.

290
00:21:19,050 --> 00:21:22,440
And the top part as well here is if blog actually.

291
00:21:24,310 --> 00:21:25,330
For our.

292
00:21:26,460 --> 00:21:28,470
Granted, location, so here.

293
00:21:29,770 --> 00:21:30,940
I'm just going to put it in here.

294
00:21:31,360 --> 00:21:38,320
Permission, access, course, location, if that was the case, then permission granted for course,

295
00:21:38,320 --> 00:21:43,330
location and accordingly, of course, this health block here.

296
00:21:45,690 --> 00:21:49,500
Will be given like, so OK.

297
00:21:50,010 --> 00:21:54,810
That's how you would solve all three options, but that's pretty much it accordingly, of course.

298
00:21:54,810 --> 00:21:55,320
Yeah, you could.

299
00:21:55,560 --> 00:21:57,900
How you should adhere to course location as well.

300
00:21:58,410 --> 00:22:00,390
So here many first permission.

301
00:22:05,100 --> 00:22:06,480
But, of course, location.

302
00:22:08,170 --> 00:22:10,810
And now I actually have never tried it this way.

303
00:22:11,260 --> 00:22:12,640
Let me try it.

304
00:22:16,290 --> 00:22:20,760
If I will, I will get asked for permission twice to run it and see.

305
00:22:22,080 --> 00:22:23,260
Well, like three times, actually.

306
00:22:24,190 --> 00:22:28,300
So ask for permission, allow an hour precise allow.

307
00:22:28,780 --> 00:22:29,370
And that's fine.

308
00:22:29,380 --> 00:22:29,610
Yeah.

309
00:22:29,940 --> 00:22:30,640
It still works.

310
00:22:30,640 --> 00:22:35,980
So it gave me the permission granted for the final location, but not for the course location.

311
00:22:36,970 --> 00:22:37,570
OK, cool.

312
00:22:38,980 --> 00:22:42,580
That's it for this video now you have an idea of how to use permissions.

313
00:22:43,210 --> 00:22:44,020
See you in the next one.

