martin suchodol
09/07/2022, 8:35 AMval url = "<https://api.openweathermap.org/data/2.5/forecast/daily?q=hamburg,de&appid=33aa634c216259f797f35e862f07****>"
val resultJson = URL(url).readText()
Log.d("Weather Report", resultJson)
val jsonObj = JSONObject(resultJson)
val main = jsonObj.getJSONObject("main")
Attempting to execute then brings up the following:
https://pastebin.com/84EDhwyU
The debug basically did not detect any faults.
Anyway, the bug refers this line:
val resultJson = URL(url).readText()
Edit:
I will add that when I played with it yesterday I somehow mysteriously managed to get the resulting JSON, but only once and without any code modification. It's as if each time the resulting JSON was loaded incorrectlyCiaran Sloan
09/07/2022, 8:55 AMCaused by: android.os.NetworkOnMainThreadException
You cannot perform network requests on the main thread. Consider shifting the request to a background thread