Sender handler = new Sender();
FormBody.Builder params= new FormBody.Builder();
params.add("param1", "val");
params.add("param2", "val");
result = handler.execute("https://domain.ru/",params).get();
Как сделать чтобы arg[0] был url , а arg[1] были параметры ?public class Sender extends AsyncTask<String, FormBody.Builder, String> {
private static final OkHttpClient client = new OkHttpClient();
protected String doInBackground(String... arg) {
try {
RequestBody formBody = arg[1].build();
Request request = new Request.Builder()
.url(arg[0])
.post(formBody)
.build();
Response response = client.newCall(request).execute();
return response.body().string();
} catch (Exception e) {
e.printStackTrace();
}
return "fail";
}
}