Android volley - avoid multiple requests of the same kind to the server? -


i using volley upload list of images server. happens within service. once image uploaded remove list. problem arises when internet connection breaks. when internet connection breaks , comes again thinking of adding images yet uploaded request queue.

this can result in more 1 copy of same image saved on server request same image might have gone through before getting rseponse.

how can address scenario?

i'm not quite sure why you're using service schedule requests volley automatically runs it's request in seperate thread.

nevertheless can listen both request results, successful , unsuccessful adding listeners.

you can remove image list schedule request using volley. if succeeds can carry on desired, if fails can add again list.

public static request getimageuploadrequest(final string image) {      response.listener<t> responselistener = new response.listener<t>() {                  @override                  public void onresponse(t response) {                      // whatever                  }      };       response.errorlistener errorlistener = new response.errorlistener() {                  @override                  public void onerrorresponse(volleyerror error) {                      // put image onto list                      someclass.addimagetolist(image);                  }      };       return new jsonarrayrequest(request.method.get, your_url, null, responselistener, errorlistener); // use subclass of request } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -