Я не могу получить местоположение, используя LocationManager.GPS_PROVIDER
. Но он работает с LocationManager.NETWORK_PROVIDER
.
val locationManager=getSystemService(Context.LOCATION_SERVICE) as LocationManager
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,500, 100F,listener)//It's working if i use NETWORK_PROVIDER
val listener=object :LocationListener {
override fun onLocationChanged(location: Location?) {
latitude = location!!.latitude.toString()
longitude = location!!.longitude.toString()
Log.d("location", "$latitude $longitude")
}
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {
}
override fun onProviderEnabled(provider: String?) {
}
override fun onProviderDisabled(provider: String?) {
}
}