Search code examples
asynchronousschedulerloopj

LoopJ asynchron Http client loopj Scheduler to repeat client.get onFailure()


I am using the Asynchronous Http Client of the LoopJ Library. I want it to become more robust, so if there is a Onfailure , the Params get saved and tried again later in a interval for example 1 hour. Now my question is, is there a possibility to grab the Requestparams in the OnFailure Callback so I can use them again later?

Or is there a better Opportunity anyone can think of?

    loginparams=new RequestParams();
    loginparams.put("username", email);
    loginparams.put("password", password);
    loginClient.doLogin(loginparams, new AsyncHttpResponseHandler() {

 @Override
                public void onFailure(int i, cz.msebera.android.httpclient.Header[] headers, byte[] bytes, Throwable throwable) {
                    checker1=false;
                    Log.v("MYLOG", "On START"+checker1);
                }

Solution

  • We can add retry:

     @Override
     public void onRetry(int retryNo) {
         // Request was retried
     }
    

    loopj-link