Welcome back.
The first step in getting the current location is to create the variable.
It's of type location and it's of mutable state.
Now the second step is the location permission launcher.
Start with val location permission launcher.
Remember launcher for activity result activity result contracts dot request permissions.
Let me explain what we create here.
This line creates a permission launcher using jetpack composes integration with the Activity Result
API.
It will be used to request the location permission at runtime, for example access, find location and
other permissions.
Since the location getting current location of the user demands and request many permissions like access,
file location and course location, we need to check that the user enable or enables the location or
not.
Okay, so this is the main purpose of this code to check if the user enable remember launcher for activity
result.
This is a composable function that creates and remembers an activity result launcher.
it allows you to launch permission requests or other activities and handle the result in a callback.
It survives recompositions automatically.
You don't need to reinitialize it every time.
Activity result.
Contracts dot request permission.
This is a contract for requesting a single time or single runtime permission.
Android will show the system permission dialog and return a boolean result.
True.
Permission granted.
False.
Permission denied.
Okay, so let me start by requesting a location and if it is granted, get the current location is granted.
So if it is true then what we need to do we need to call a function called fetch current location.
So here in this video we learned about activity result contracts and remember launcher for activity
result.
Here we are requesting from the user to grant the permission and if it is granted, we need to fetch
the current location.
In the next video we're going to create this function to get the current location.