I decided to give Volley a try, so presently I have a lot of REST callouts to be done, so I usually create a RequestHandler and a ResponseHandler class which as their names sugg
I use volley, and this is what I do. The code goes anywhere in your activity.
import com.android.volley.Response.Listener;
import static com.android.volley.Response.ErrorListener;
Listener successListener = new Listener() {
@Override
public void onResponse(YOURDATACLASS data) {
// Check to make sure that the activity hasn't been destroyed while the call was in flight.
if (! isFinishing()) {
//DO YOUR UI UPDATE, such as
TextView textview = (TextView) findViewById(R.id.yourtextview);
textview.setText("blah blah blah");
}
}
};
ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//DO SOMETHING ON FAILURE
}
YOURAPICALL(successListener, failurelistener);