Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2017 07:09
What would you like to do?
fun findMeButtonClick(view: View) {
val locationManager = applicationContext.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val bestProvider = locationManager.getBestProvider(Criteria(), false)
val location = locationManager.getLastKnownLocation(bestProvider)
if (location != null) {
longitude.text = location.longitude.toString()
latitude.text = location.latitude.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment