Code example for Handler

0
    protected void onPreExecute() { 
        super.onPreExecute(); 
 
        if (requests.getCallbackHandler() == null) {
            // We want any callbacks to go to a handler on this thread unless a handler has already been specified. 
            requests.setCallbackHandler(new Handler());
        } 
    } 
 
    @Override 
    protected void onPostExecute(List<Response> result) {
        super.onPostExecute(result);
 
        if (exception != null) {
            Log.d(TAG, String.format("onPostExecute: exception encountered during request: %s", exception.getMessage()));
        } 
    } 
 
    @Override 
    protected List<Response> doInBackground(Void... params) {
        try {