Skip to content

Instantly share code, notes, and snippets.

@DawnImpulse
Created September 21, 2019 09:43
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 DawnImpulse/3802834d6d5c32d5d825202d6af6edd0 to your computer and use it in GitHub Desktop.
Save DawnImpulse/3802834d6d5c32d5d825202d6af6edd0 to your computer and use it in GitHub Desktop.
Get fine location android
locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10f, LocationListenerCallback)
} else if (F.isConnected(this)) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 10f, LocationListenerCallback)
} else
toast("kindly enable either GPS / Internet to get location")
// for opening gps settings activity
startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment