OkHttp的post請求

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) {ide

}post

@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);
  }
}
});ui

相關文章
相關標籤/搜索