1
00:00:00,580 --> 00:00:06,060
Hire everyone in this tutorial I want to talk about actually getting the users location.

2
00:00:06,110 --> 00:00:11,100
We're going to build an application actually there is a lot like Uber.

3
00:00:11,350 --> 00:00:17,550
So here we are going to actually get the user's location using the GPS and Android permissions.

4
00:00:17,770 --> 00:00:22,270
So first let me tell you that let's actually click on configure and click on as the case manager.

5
00:00:22,660 --> 00:00:29,070
So here make sure that you have installed at least one of these eyes and reach seven point 1.1 no get

6
00:00:29,320 --> 00:00:34,250
Android 7.0 no get and and it's six point zero marshmallow.

7
00:00:34,280 --> 00:00:42,190
OK one of these is the case one of these AP It is necessary if you want to actually use it if you want

8
00:00:42,190 --> 00:00:44,410
to actually create this application.

9
00:00:44,410 --> 00:00:49,100
So here if you want to we can actually package details here.

10
00:00:49,270 --> 00:00:53,710
As you can see according to my operating system we can actually install one of these packages.

11
00:00:53,710 --> 00:00:54,070
OK.

12
00:00:54,310 --> 00:00:58,710
So if you just just choose one of these.

13
00:00:58,810 --> 00:01:06,220
Actually one of these API is is going to automatically download and install the required packages for

14
00:01:06,220 --> 00:01:07,970
your operating system.

15
00:01:07,990 --> 00:01:14,950
So let's get to the key Tools tab and here make sure that you have installed an updated Android SDK

16
00:01:14,950 --> 00:01:24,560
built tools Android emulator Android platform dash tools and SDK tools Android support library GPU the

17
00:01:24,910 --> 00:01:31,390
debugging tools and all these packages and also make sure that you have installed and updated support

18
00:01:31,390 --> 00:01:32,410
repository.

19
00:01:32,450 --> 00:01:33,570
OK.

20
00:01:34,070 --> 00:01:38,260
Especially Google repository and Android support repository.

21
00:01:38,260 --> 00:01:39,390
So that's it.

22
00:01:39,400 --> 00:01:46,990
Now let's click on OK let's create a new Android studio project and for the application name here just

23
00:01:46,990 --> 00:01:48,840
a plain G.

24
00:01:48,880 --> 00:01:51,440
P.S. location app

25
00:01:54,190 --> 00:01:56,560
so you can specify the company domain.

26
00:01:56,710 --> 00:02:01,130
You can specify the package name here and make sure that you have unchecked this checkbox because you

27
00:02:01,130 --> 00:02:04,710
are not going to use C++ in this application.

28
00:02:04,840 --> 00:02:11,740
And here you can specify the project locations to just click next and here a target API 16 as the minimum

29
00:02:11,800 --> 00:02:12,610
is the case.

30
00:02:12,820 --> 00:02:18,210
So it's as though API levels target more devices but have fewer features available.

31
00:02:18,670 --> 00:02:26,890
So here it is by targeting API 16 Lader your app will run on approximately ninety five point two percent

32
00:02:26,890 --> 00:02:30,120
of the devices that are active on the Google Play store.

33
00:02:30,190 --> 00:02:36,790
So he has to APX 16 and choose phone and tablet make sure that you have actually checked these checkbox

34
00:02:36,820 --> 00:02:43,430
and then click on next choose MT activity next and dont change anything.

35
00:02:43,540 --> 00:02:44,920
Just click on finish.

36
00:02:45,310 --> 00:02:50,980
So now that the project is actually created Let's go to the activity on the alignment of the exam and

37
00:02:50,980 --> 00:02:55,060
here let me actually does just double click on the step in order to make this area by there.

38
00:02:55,060 --> 00:02:57,890
So in this story you are going to use constraint.

39
00:02:57,940 --> 00:03:02,400
So here we can see that inside this componentry section it says constrained to leave out right.

40
00:03:02,440 --> 00:03:07,020
If I actually click on this text up here at the bottom you can see that we have this constraint out

41
00:03:07,090 --> 00:03:07,740
as the default.

42
00:03:07,840 --> 00:03:11,020
So if you dont have to constrain to leave out as the default.

43
00:03:11,170 --> 00:03:14,580
Make sure that you have actually make sure to change to constraints.

44
00:03:14,620 --> 00:03:18,040
Because you are going to use constraints here in this application.

45
00:03:18,040 --> 00:03:19,630
So lets go back to design.

46
00:03:20,170 --> 00:03:25,870
And here let me just select this hello world takes view and present you on your keyboard and hid inside

47
00:03:25,870 --> 00:03:27,870
this pallet section here.

48
00:03:27,940 --> 00:03:33,660
If I click on all you can see this takes you here just selected and to strike it and put it here.

49
00:03:34,550 --> 00:03:40,250
Center horizontal energy and see these guys here that are actually telling me that we can actually put

50
00:03:40,460 --> 00:03:43,630
position this takes you according to these guidelines.

51
00:03:43,670 --> 00:03:50,870
So lets just position it here just select its takes view and first let me tell you that look at these

52
00:03:50,900 --> 00:03:54,910
options here it says Sure constraints as you can see currently is hidden.

53
00:03:54,920 --> 00:04:01,140
If I click on it now now it's going to show us the constraints and he'll look at this option here this

54
00:04:01,530 --> 00:04:07,670
icon it says what it is turn up or to connect so that other kind of act is now turned on.

55
00:04:07,830 --> 00:04:08,070
OK.

56
00:04:08,070 --> 00:04:16,180
This means that the constraints is going to be automatically created for me according to how I position

57
00:04:16,220 --> 00:04:21,280
these components inside art actually lay out constraints.

58
00:04:21,540 --> 00:04:25,620
So I put this text here and it automatically created these constraints for me.

59
00:04:25,620 --> 00:04:32,880
Here you can see inside these properties section that it says that we have these margins here for example

60
00:04:32,880 --> 00:04:35,240
16 Margene from the top.

61
00:04:35,250 --> 00:04:38,490
And for now don't worry about these margins.

62
00:04:38,490 --> 00:04:44,260
So just select this text view and let's pro-white an ID for the state's view.

63
00:04:44,280 --> 00:04:52,760
So for the ID just type in here he the location and that person entered key on your keyboard.

64
00:04:52,760 --> 00:04:55,200
So now you can see is the size constraints.

65
00:04:55,220 --> 00:04:59,120
And if they actually hover over this size constraint it says Lappe content.

66
00:04:59,120 --> 00:05:03,620
So this means that the width of this text view is that up content.

67
00:05:03,620 --> 00:05:08,660
So that's what you can see that the margin left and the margin right is zero and the text is at the

68
00:05:08,660 --> 00:05:10,070
center.

69
00:05:10,070 --> 00:05:12,290
So let's click on this size constraint here.

70
00:05:12,530 --> 00:05:17,450
So it is now fixed and it's actually going to take and now we can see that it is actually match parent.

71
00:05:17,510 --> 00:05:17,690
Right.

72
00:05:17,690 --> 00:05:20,600
It is actually taking the match constraints right.

73
00:05:20,600 --> 00:05:23,350
If I click on here you can see that here.

74
00:05:23,390 --> 00:05:30,350
So now you can see that the margin lift and the margin right of this takes view here is actually zero.

75
00:05:30,350 --> 00:05:38,240
So it is actually attached to the right edge of this play out and it is actually also attached to the

76
00:05:38,240 --> 00:05:40,480
left edge of this play out here.

77
00:05:40,580 --> 00:05:41,210
Right.

78
00:05:41,210 --> 00:05:44,160
So let's actually change it back to the content.

79
00:05:44,210 --> 00:05:49,060
So now it's like it's actually changed back to rap content.

80
00:05:49,190 --> 00:05:54,890
But I want this takes you to be at the center here center horizontal so it's actually select it and

81
00:05:54,890 --> 00:05:57,260
put it here center horizontally.

82
00:05:57,650 --> 00:06:01,520
So now you can see that our view is actually centered horizontally.

83
00:06:01,520 --> 00:06:04,100
Now let's take this text view.

84
00:06:04,340 --> 00:06:06,280
And I want to change the text of this text view.

85
00:06:06,290 --> 00:06:18,580
So here just select is text attribute and just typing here or location latitudes and longitudes.

86
00:06:18,690 --> 00:06:24,600
So in order to access a specific location in Android we must have access to the latitude and longitude.

87
00:06:24,600 --> 00:06:30,810
These coordinates are very important because otherwise you not we can actually access the user's location

88
00:06:30,840 --> 00:06:32,300
or any other location.

89
00:06:32,370 --> 00:06:37,740
This latitude and longitude coordinates are going to actually give us the information that we need for

90
00:06:37,740 --> 00:06:39,740
a specific location on the air.

91
00:06:39,810 --> 00:06:44,960
So let's go and let's see how we can actually access these coordinates.

92
00:06:44,970 --> 00:06:47,140
Let's go to the main activity class.

93
00:06:47,460 --> 00:06:55,250
So now let's create a constant inside our R-Maine activity class or just open here public static find

94
00:06:55,400 --> 00:07:04,660
all stream streaming but it is a convention in Java to actually capitalize our constant names.

95
00:07:04,790 --> 00:07:10,820
So here I can just say tag that is actually you can see that these letters are actually capitalized

96
00:07:11,120 --> 00:07:17,210
and I put an assignment operator on here two coats and here I can assign the value cap tack to this

97
00:07:17,630 --> 00:07:20,000
constant just that you are rated.

98
00:07:20,000 --> 00:07:22,220
Use it later for now don't worry about it.

99
00:07:22,310 --> 00:07:25,780
Now we need to go to the build that that great file.

100
00:07:25,790 --> 00:07:28,600
Actually the applet will be that credit file.

101
00:07:28,820 --> 00:07:33,820
So at the top end you just click on View tool windows and then click on Project.

102
00:07:33,830 --> 00:07:37,860
Now open this app folder here you can see this cradle excretes right.

103
00:07:37,880 --> 00:07:38,440
Right.

104
00:07:38,450 --> 00:07:42,950
So make sure that you have inside your inside this and right view if you're not you just need to click

105
00:07:42,950 --> 00:07:43,560
on this.

106
00:07:43,970 --> 00:07:46,790
This button here you can see these two little triangles here.

107
00:07:46,790 --> 00:07:48,950
If you click on it just click on Android.

108
00:07:48,980 --> 00:07:53,960
So now open this cradle secrets and here you can see that you have two foils with the same name.

109
00:07:53,960 --> 00:07:56,170
The first one is built that cradle file.

110
00:07:56,200 --> 00:07:59,300
This is actually the project level great device.

111
00:07:59,480 --> 00:08:04,510
Now I want to go to the beat that great you'll find there is actually called module.

112
00:08:04,640 --> 00:08:06,240
The applet will be that great.

113
00:08:06,320 --> 00:08:08,580
So just double click on this wide open.

114
00:08:08,930 --> 00:08:15,730
So an elevator tab here up at the top in order to make this actually is elevator this wide.

115
00:08:15,980 --> 00:08:19,800
Now you can see this dependences block here at the bottom right.

116
00:08:19,850 --> 00:08:24,890
So let's go inside is dependences block and below it is this compiled line of code here.

117
00:08:25,100 --> 00:08:31,660
Now I'm going to actually just type in comp. So I'm going to paste a value here so you can see this

118
00:08:31,660 --> 00:08:32,870
value here right.

119
00:08:32,870 --> 00:08:35,840
Just put a pair of coats here.

120
00:08:35,900 --> 00:08:37,980
Make sure that it is actually a single code.

121
00:08:38,000 --> 00:08:38,970
It is not the table.

122
00:08:38,990 --> 00:08:42,190
It is actually a single coat and inside single quotes.

123
00:08:42,350 --> 00:08:52,610
You just need to put Come dot Google dot Android that GM is GM GM as Colin play dash Silvey says call

124
00:08:52,620 --> 00:09:01,920
in six point five point eighty seven and then you can see these and D-NJ actually code here right.

125
00:09:01,940 --> 00:09:04,610
So at the top you can see it's seen now.

126
00:09:04,730 --> 00:09:12,740
Right it says Gretl files have changed since last project sinch a project sinch may be necessary for

127
00:09:12,740 --> 00:09:18,930
the ID to work properly so we must see in our project now so just click on sinch now.

128
00:09:19,250 --> 00:09:25,860
So now that the project is actually seen successfully here make sure that you have no problems here.

129
00:09:26,030 --> 00:09:31,160
If you have any problems please post the discussion in the course because if you have any problems at

130
00:09:31,160 --> 00:09:36,700
this point you're going to have problems actually continuing this tutorial.

131
00:09:36,860 --> 00:09:41,000
So make sure that you have actually installed the Google repository package.

132
00:09:41,000 --> 00:09:45,650
Let me show you that package here at the top and you just get to an android studio and click on preferences.

133
00:09:45,950 --> 00:09:49,810
And here you can see just open this system settings.

134
00:09:49,840 --> 00:09:50,870
Android is the key.

135
00:09:50,990 --> 00:09:56,440
If I go to the SDK tools make sure that you have installed the supports repository here Android support

136
00:09:56,450 --> 00:09:57,940
repository Google repository.

137
00:09:57,950 --> 00:10:00,200
These are the required packages.

138
00:10:00,220 --> 00:10:03,060
OK so let me actually just kind of OK.

139
00:10:03,190 --> 00:10:04,650
Now everything is fine right.

140
00:10:04,670 --> 00:10:09,220
Let's go to the main activity class and I want to do something here.

