In my program, I want to get a string with the name of the city that corresponds to the location on the phone. I have the geocoder code:
class LocationData : LocationDataInterface{
    var result: String = ""
     override fun getAdreesTown(location: Location, context: Context): String {
         val thread = Thread(
             Runnable {
                 val geocoder = Geocoder(context, Locale.getDefault())
                 try{
                     var list: List<Address> = geocoder. getFromLocation(location.getLatitude(), location.getLongitude(), 1)
                     if(list != null && list.size > 0){
                         var address : Address = list.get(0) as Address
                         result = "${address. getAddressLine(0)}  , ${address.getLocality()}"
                     }
                 }catch(e: IOException){
                     Log.d("Egor", "Подключение к геокодеру не установлено: $e.message")
             }
             }).run()
         thread.start()
         return result
         }
    }
Permission to request location is specified in the Manifest:
<uses-permission android:name = "android.permission.ACCESS_COARSE_LOCATION"/>
My problem is that I do not know how to get the Location object with the current location to pass to the Geocoder. I tried different options (for example, fusedLocationClient), but nothing worked.
class MainActivity : AppCompatActivity(), DataProcessingCallback {
\\ 
lateinit var locationData: LocationDataInterface
\\
override fun onCreate(savedInstanceState: Bundle?) {
locationData = LocationData()
val e = locationData.getAdreesTown(Location(LocationManager.NETWORK_PROVIDER), this)
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
        fusedLocationClient.lastLocation.addOnSuccessListener { location : Location? ->
            locationNow = location
        }
        val e = locationData.getAdreesTown(location, this)
How do I create a location object with the current location?
