Leku
Leku copied to clipboard
NetworkClient.java line 39 (Caused by java.io.InterruptedIOException: thread interrupted)
Please provide proper solution for this issue:
fun requestFromLocationName(request: String): String? { var result: String? = null var stream: InputStream? = null var connection: HttpsURLConnection? = null try { val url = URL(request) Log.e("GeocodingUrl--", "" + request) connection = url.openConnection() as HttpsURLConnection connection.readTimeout = READ_TIMEOUT connection.connectTimeout = CONNECT_TIMEOUT connection.requestMethod = "GET" connection.doInput = true connection.connect()
**val responseCode = connection.responseCode**
if (responseCode != HttpsURLConnection.HTTP_OK) {
throw NetworkException("HTTP error code: $responseCode")
}
stream = connection.inputStream
if (stream != null) {
result = readStream(stream, REPONSE_MAX_LENGTH)
}
} catch (ignore: UnknownHostException) {
} catch (ioException: IOException) {
throw NetworkException(ioException)
} finally {
if (stream != null) {
try {
stream.close()
} catch (ioException: IOException) {
throw NetworkException(ioException)
}
}
connection?.disconnect()
}
return result
}