使用OkHttpClient进行网络请求

OkHttpClient okHttpClient = new OkHttpClient();
RequestBody body = new FormBody.Builder()
        .add("SamplePerson",userName+"")
        .add("RegionID",signPass+"")
        .add("BluetoothValue",content+"")
        .build();
final Request request = new Request.Builder().url("http://www.canyinanquan.com/api/BluetoothAdd?format=json")
        .post(body)
        .build();

okHttpClient.newCall(request).enqueue(new Callback() {
    @Override
    public void onFailure(Call call, IOException e) {

    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {
        String string = response.body().string();
        
    }
});


猜你喜欢

转载自blog.csdn.net/weikai_/article/details/80162061
今日推荐