使用谷歌官方库volley进行http请求
2018-01-03 10:57
134 查看
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) }
相关文章推荐
- 谷歌地图在中国能使用了?谷歌官方回应 | 消息
- BaiduMap---百度地图官方Demo之OpenGL绘制功能(介绍如何使用OpenGL绘制在地图中进行绘制)
- Android中的应用——谷歌官方Json分析工具Gson使用
- FC4初步使用体验--fox进行更新,添加官方安装指南
- 使用OpenCV进行人脸识别的三种算法(官方网翻译)
- 使用 APICloud 官方提供的开发工具APICloud Studio 2 进行开发
- 使用Apache中的HttpClient的实例CloseableHttpClient进行http请求
- android 为什么谷歌官方不建议在项目中使用 Enum
- 使用Spring的restTemplete进行Http请求
- phonegap 开发入门 PhoneGap官方网站上有详细的入门示例教程,这里,我针对使用PhoneGap进行Android移动应用的开发对其官网的Get Started进行一些介绍、补充。 Ste
- 使用谷歌开源组件tesseract-OCR识别身份证,通过opencv处理图像后再进行识别(windows版本)
- [Andriod官方训练教程]使用Fragment创建一个动态的UI之与其他Fragments进行交互
- 使用jMeter构造大量并发HTTP请求进行微服务性能测试
- Android官方开发文档Training系列课程中文版:后台加载数据之使用CursorLoader进行查询
- [Andriod官方训练教程]使用Fragment创建一个动态的UI之与其他Fragments进行交互
- Linux下使用curl进行http请求(转)
- 使用DevExpress官方汉化文件对界面进行汉化的过程
- 使用JMeter进行性能测试之——HTTP请求
- uboot移植——使用三星官方的uboot进行移植