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?
You should add the following property in <application>
tag of AndroidManifest.xml file: cleartextTrafficPermitted="true"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.