Hire everyone in this tutorial I want to talk about actually getting the users location.
We're going to build an application actually there is a lot like Uber.
So here we are going to actually get the user's location using the GPS and Android permissions.
So first let me tell you that let's actually click on configure and click on as the case manager.
So here make sure that you have installed at least one of these eyes and reach seven point 1.1 no get
Android 7.0 no get and and it's six point zero marshmallow.
OK one of these is the case one of these AP It is necessary if you want to actually use it if you want
to actually create this application.
So here if you want to we can actually package details here.
As you can see according to my operating system we can actually install one of these packages.
OK.
So if you just just choose one of these.
Actually one of these API is is going to automatically download and install the required packages for
your operating system.
So let's get to the key Tools tab and here make sure that you have installed an updated Android SDK
built tools Android emulator Android platform dash tools and SDK tools Android support library GPU the
debugging tools and all these packages and also make sure that you have installed and updated support
repository.
OK.
Especially Google repository and Android support repository.
So that's it.
Now let's click on OK let's create a new Android studio project and for the application name here just
a plain G.
P.S. location app
so you can specify the company domain.
You can specify the package name here and make sure that you have unchecked this checkbox because you
are not going to use C++ in this application.
And here you can specify the project locations to just click next and here a target API 16 as the minimum
is the case.
So it's as though API levels target more devices but have fewer features available.
So here it is by targeting API 16 Lader your app will run on approximately ninety five point two percent
of the devices that are active on the Google Play store.
So he has to APX 16 and choose phone and tablet make sure that you have actually checked these checkbox
and then click on next choose MT activity next and dont change anything.
Just click on finish.
So now that the project is actually created Let's go to the activity on the alignment of the exam and
here let me actually does just double click on the step in order to make this area by there.
So in this story you are going to use constraint.
So here we can see that inside this componentry section it says constrained to leave out right.
If I actually click on this text up here at the bottom you can see that we have this constraint out
as the default.
So if you dont have to constrain to leave out as the default.
Make sure that you have actually make sure to change to constraints.
Because you are going to use constraints here in this application.
So lets go back to design.
And here let me just select this hello world takes view and present you on your keyboard and hid inside
this pallet section here.
If I click on all you can see this takes you here just selected and to strike it and put it here.
Center horizontal energy and see these guys here that are actually telling me that we can actually put
position this takes you according to these guidelines.
So lets just position it here just select its takes view and first let me tell you that look at these
options here it says Sure constraints as you can see currently is hidden.
If I click on it now now it's going to show us the constraints and he'll look at this option here this
icon it says what it is turn up or to connect so that other kind of act is now turned on.
OK.
This means that the constraints is going to be automatically created for me according to how I position
these components inside art actually lay out constraints.
So I put this text here and it automatically created these constraints for me.
Here you can see inside these properties section that it says that we have these margins here for example
16 Margene from the top.
And for now don't worry about these margins.
So just select this text view and let's pro-white an ID for the state's view.
So for the ID just type in here he the location and that person entered key on your keyboard.
So now you can see is the size constraints.
And if they actually hover over this size constraint it says Lappe content.
So this means that the width of this text view is that up content.
So that's what you can see that the margin left and the margin right is zero and the text is at the
center.
So let's click on this size constraint here.
So it is now fixed and it's actually going to take and now we can see that it is actually match parent.
Right.
It is actually taking the match constraints right.
If I click on here you can see that here.
So now you can see that the margin lift and the margin right of this takes view here is actually zero.
So it is actually attached to the right edge of this play out and it is actually also attached to the
left edge of this play out here.
Right.
So let's actually change it back to the content.
So now it's like it's actually changed back to rap content.
But I want this takes you to be at the center here center horizontal so it's actually select it and
put it here center horizontally.
So now you can see that our view is actually centered horizontally.
Now let's take this text view.
And I want to change the text of this text view.
So here just select is text attribute and just typing here or location latitudes and longitudes.
So in order to access a specific location in Android we must have access to the latitude and longitude.
These coordinates are very important because otherwise you not we can actually access the user's location
or any other location.
This latitude and longitude coordinates are going to actually give us the information that we need for
a specific location on the air.
So let's go and let's see how we can actually access these coordinates.
Let's go to the main activity class.
So now let's create a constant inside our R-Maine activity class or just open here public static find
all stream streaming but it is a convention in Java to actually capitalize our constant names.
So here I can just say tag that is actually you can see that these letters are actually capitalized
and I put an assignment operator on here two coats and here I can assign the value cap tack to this
constant just that you are rated.
Use it later for now don't worry about it.
Now we need to go to the build that that great file.
Actually the applet will be that credit file.
So at the top end you just click on View tool windows and then click on Project.
Now open this app folder here you can see this cradle excretes right.
Right.
So make sure that you have inside your inside this and right view if you're not you just need to click
on this.
This button here you can see these two little triangles here.
If you click on it just click on Android.
So now open this cradle secrets and here you can see that you have two foils with the same name.
The first one is built that cradle file.
This is actually the project level great device.
Now I want to go to the beat that great you'll find there is actually called module.
The applet will be that great.
So just double click on this wide open.
So an elevator tab here up at the top in order to make this actually is elevator this wide.
Now you can see this dependences block here at the bottom right.
So let's go inside is dependences block and below it is this compiled line of code here.
Now I'm going to actually just type in comp. So I'm going to paste a value here so you can see this
value here right.
Just put a pair of coats here.
Make sure that it is actually a single code.
It is not the table.
It is actually a single coat and inside single quotes.
You just need to put Come dot Google dot Android that GM is GM GM as Colin play dash Silvey says call
in six point five point eighty seven and then you can see these and D-NJ actually code here right.
So at the top you can see it's seen now.
Right it says Gretl files have changed since last project sinch a project sinch may be necessary for
the ID to work properly so we must see in our project now so just click on sinch now.
So now that the project is actually seen successfully here make sure that you have no problems here.
If you have any problems please post the discussion in the course because if you have any problems at
this point you're going to have problems actually continuing this tutorial.
So make sure that you have actually installed the Google repository package.
Let me show you that package here at the top and you just get to an android studio and click on preferences.
And here you can see just open this system settings.
Android is the key.
If I go to the SDK tools make sure that you have installed the supports repository here Android support
repository Google repository.
These are the required packages.
OK so let me actually just kind of OK.
Now everything is fine right.
Let's go to the main activity class and I want to do something here.