码迷,mamicode.com
首页 > Web开发 > 详细

OkHttp的post请求

时间:2016-07-01 08:59:14      阅读:310      评论:0      收藏:0      [点我收藏+]

标签:

OkHttpClient client = new OkHttpClient();
FormBody body = new FormBody.Builder()
.add("mobile",mNumber)
.add("type","1").build();
final Request request = new Request.Builder()
.url(mPath)
.post(body).build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {

}

@Override
public void onResponse(Call call, Response response) throws IOException {
  if (response.isSuccessful()){
    String d = response.body().string();
    Gson gson = new Gson();
    RegisterData data = gson.fromJson(d, RegisterData.class);
    Message msg = Message.obtain();
    msg.obj = data;
    handler.sendMessage(msg);
  }
}
});

OkHttp的post请求

标签:

原文地址:http://www.cnblogs.com/bwandroid/p/5631771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!