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
Post a Comment