I will be remembered when I'm in heaven. People won't remember my name, but they will know the photographer who did that picture of that nurse being kissed by the sailor at the end of World War II. Everybody remembers that.

Alfred Eisenstaedt

menú
 

RestazoClient v1b (© José M. Carnero)

Proyecto en GitHub: github.com/jmcarnero/RestazoClient

Cliente REST para Android.

Ésta librería permite realizar peticiones a servicios REST de forma asíncrona. Devuelve los datos recuperados (o los errores, si fuera el caso) como hashmap.

Si bien es funcional todavía está en fase beta; queda mucho por hacer.

Ejemplo de uso:

RestazoClient.RestazoClientCallback resCallback = new RestazoClient.RestazoClientCallback() {
    @Override
    public Boolean onCallback(Map aResult){
        TextView tvInfo = (TextView)findViewById(R.id.textView_info);

        String sText = "Cargando...";

        if (!aResult.isEmpty()) {
            String sStatus = (String) aResult.get("status");
            String  sError = (String) aResult.get("error");

            if (sError != null && !sError.isEmpty()) {
                tvInfo.setText("Error: " + sError);
                return false;
            }

            sText = sStatus;

            if (sStatus.equals("done")) {
                sText = "Finalizada recuperación";
                tvInfo.setVisibility(View.INVISIBLE);
            }

            tvInfo.setText(sText);
        }

        return true;
    }
};

new RestazoClient(resCallback).execute("http://example.com/rest", "post", "param1=0", "param2=5");
	

Si no se requieren parametros ni tipo de petición (GET por defecto) puede llamarse con:

new RestazoClient(resCallback).execute("http://example.com/rest");
	

Testeo en Android 4.4.