Lo he vuelto a subir esta vez mucho más claro, perdón por las molestias jaja
************************************************** ****************
Código HTML:
static String result="hol";
String post(String url, String... parametros) throws IOException
{
OkHttpClient client = new OkHttpClient();
FormBody.Builder builder = new FormBody.Builder();
builder.add(parametros[0], parametros[1]);
builder.add(parametros[2], parametros[3]);
RequestBody formBody = builder.build();
Request request = new Request.Builder()
.url(url)
.post(formBody)
.build();
Call call = client.newCall(request);
call.enqueue(new okhttp3.Callback()
{
@Override
public void onFailure(Call call, IOException e)
{
Log.e("TAG", "(onFailure) The request was not successful");
}
@Override
public void onResponse(Call call, Response response) throws IOException
{
try
{
if (response.isSuccessful())
{
result = response.body().string();
Log.v("RESPUESTA", "Resultado:" +result);
} else
{
Log.v("TAG", "(onResponse) Was not successful");
}
} catch (IOException e)
{
Log.e("TAG", "Exception caught: ", e);
}
}
});
return result;
}
************************************************** ***************