1

i'm trying to build a weather app as my first time working with and api so i'm starting with the documentations and still not getting a response

fun getWeather(view:View){
        val city = cityName.text.toString()
        cityName.text.clear()
        //val  url = "api.openweathermap.org/data/2.5/weather?q=$city&appid=cb8d284902f295b8759aa295cb6bafc3"
        val url = "https://www.google.com"
        val queue = Volley.newRequestQueue(this)
        val stringRequest = StringRequest(Request.Method.GET,url, Response.Listener<String> {
            response ->
            weatherResult.text = "it worked" + response.substring(0,10)
        },Response.ErrorListener {
            weatherResult.text = "there was an error"
        })
        queue.add(stringRequest)

    }
Mario Nan
  • 25
  • 4

1 Answers1

0

I guess it should be problem with your URL. I notice that api.openweathermap.org doesn't contains https:// header in it.

Try to add https://api.openweathermap.org/ followed by your search criteria and it should work as expected.

rasfarrf5
  • 219
  • 1
  • 5