【发布时间】:2021-02-25 06:48:23
【问题描述】:
我尝试使用 Volley 来获得 JSON 响应,但出现了问题。
这是我的代码。
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)
}
但它总是要求
com.android. volley. NoConnectionError: java.io. IOException: Cleartext HTTP traffc to localhost not permitted
服务器是从 IIS 构建的。 我在哪里可以更改我的代码?
【问题讨论】:
标签: android kotlin request android-volley httpresponse