0

I tried using Volley to get JSON response but it comes something wrong.

This is my Code.

private fun sendGet() {
        val queue = Volley.newRequestQueue(this)
        val url = "http://localhost/Book/all"

        val stringRequest = JsonObjectRequest(Request.Method.GET, url, null,
                { response ->
                    // Display the first 500 characters of the response string.
                    text!!.text = response.toString()
                },
                { error ->
                    text!!.text = error.toString() })

        queue.add(stringRequest)
    }

But it always requests

com.android. volley. NoConnectionError: java.io. IOException: Cleartext HTTP traffc to localhost not permitted

The server is built from IIS. Where can I change my Code?

張聖坤
  • 5
  • 2
  • Please refer this : https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – Kabir Nov 13 '20 at 09:09

1 Answers1

1

You should add the following property in <application> tag of AndroidManifest.xml file: cleartextTrafficPermitted="true"

Iffat Fatima
  • 1,610
  • 2
  • 16
  • 27
myst
  • 51
  • 2