Skip to content

Instantly share code, notes, and snippets.

@Lavanyagaur22
Last active April 26, 2020 12:18
Show Gist options
  • Save Lavanyagaur22/60ab8a93bb12f22d5992ebde06f2cb61 to your computer and use it in GitHub Desktop.
Save Lavanyagaur22/60ab8a93bb12f22d5992ebde06f2cb61 to your computer and use it in GitHub Desktop.
fusedLocationProviderClient.lastLocation.apply {
addOnFailureListener{
//Handle the failure of the call. You can show an error dialogue or a toast stating the failure in receiving location.
}
addOnSuccessListener {
//Got last known location. (Can be null sometimes)
//You ca extract the details from the client, like the latitude and longitude of the place and use it accordingly.
myLat = it.latitude
myLong = it.longitude
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment