You could use AsyncHttpClient . I have not used it but seeing examples could do something like this:
// el json a enviar
JSONObject params = new JSONObject();
params.put("from", "xxxxx");
params.put("message", "xxxxx");
params.put("frag", "");
// configuración del Realm para la autenticación
Realm realm = new Realm.RealmBuilder()
.setPrincipal(user)
.setPassword(admin)
.setUsePreemptiveAuth(true)
.setScheme(AuthScheme.DIGEST)
.build();
// establecemos el header
StringEntity entity = new StringEntity(jsonParams.toString());
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
// enviamos la petición pasándole la url, la entidad, el mime type y el handler para ella.
client.post('http://xxxxx', entity, 'application/json', new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
// hacer algo
}
})).setRealm(realm).execute();
The advantage is that you can make a request without depending on cURL, you only add the library to your project and that's it.