kotlin注册举例
fun register(email: String, password: String, complete: (Boolean) -> Unit) { val jsonBody = JSONObject() jsonBody.put("email", email) jsonBody.put("password", password) val requestBody = jsonBody.toString() val registerRequest = object : StringRequest( Method.POST, URL_REGISTER, Response.Listener { response -> println(response) complete(true) }, Response.ErrorListener { error -> Log.d("ERROR", "Could not register user") complete(false) }) { override fun getBodyContentType(): String { return "application/json; charset=utf-8" } override fun getBody(): ByteArray { return requestBody.toByteArray() } } App.preference.requestQueue.add(registerRequest) }