geoCoder.getFromLocation 에러
private fun updateUI(){ locationProvider = LocationProvider(this@MainActivity) var latitude : Double? = locationProvider.getLocationLatitude() var longitude : Double? = locationProvider.getLocationLongitude() if(latitude != null || longitude != null){ //1. 현재 위치를 가져오고 UI를 Update val address = getCurrentAddress(latitude!!, longitude!!) address?.let{ binding.tvLocationTittle.text = "${it.thoroughfare}" binding.tvLocationSubtittle.text = "${it.countryName} ${it.adminArea}" } //2. 미세먼지 농도 가져오고 UI를 Update }else { Toast.makeText(this,"위도, 경도 정보를 가져올 수 없습니다.",Toast.LENGTH_LONG).show() } } private fun getCurrentAddress(latitude : Double, longitude : Double) : Address?{ val geocoder = Geocoder(this, Locale.KOREA) val addresses : List try { addresses = geocoder.getFromLocation(latitude, longitude, 7)!! }catch (ioException : IOException){ Toast.makeText(this,"geocoder 서비스를 이용불가 합니다.",Toast.LENGTH_LONG).show() return null }catch (illegalArgumentException : java.lang.IllegalArgumentException){ Toast.makeText(this,"잘못된 위도, 경도 입니다.",Toast.LENGTH_LONG).show() return null } if(addresses == null || addresses.size == 0){ Toast.makeText(this,"주소를 찾을 수 없습니다.",Toast.LENGTH_LONG).show() return null } return addresses[0] }