Hey, so I'm trying to use URL from the java.net.URL, to read the data from an API as a string using URL like this;
response = URL("https://api.openweathermap.org/data/2.5/weather?q=$CITY&units=metric&appid=$API").readText()
anyway everything should be working, but while debugging I can see that it says "Method threw 'java.net.SocketException' exception. Anybody know what's wrong?
I heard something before about thread blocking?
response = URL("https://api.openweathermap.org/data/2.5/weather?q=$CITY&units=metric&appid=$API").readText()
anyway everything should be working, but while debugging I can see that it says "Method threw 'java.net.SocketException' exception. Anybody know what's wrong?
I heard something before about thread blocking?
Code:
override fun doInBackground(vararg params: String?): String? {
var response:String?
try{
response = URL("https://api.openweathermap.org/data/2.5/weather?q=$CITY&units=metric&appid=$API").readText()
}catch (e: Exception){
response = null
}
return response
}