Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created September 13, 2017 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/d519a9188f21e246f682f11f8617bc10 to your computer and use it in GitHub Desktop.
Save jezinka/d519a9188f21e246f682f11f8617bc10 to your computer and use it in GitHub Desktop.
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