Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid volley is sending information twice with image upload
    text
    copied!<p>I am trying to send an image with my post data to my server from android. To accomplish this I base 64 encoded my image to string and sent it using the android volley library. This is causing problems though. For some reason it sometimes sends the post twice, and I cannot figure out why. Below is the function that is called to send the post request. I put a break mark at the <code>String url = "http://domain.com/ajax_ws.php";</code> and then one at the <code>protected Map&lt;String, String&gt; getParams() {</code> What I found is the <code>String url = ...</code> is only being called once but when it sends two, the <code>protected Map...</code> is called twice. I can't find any documentation on the android volley so I don't know why this is happening. The bitmap is resized so the image string is somewhere between 100k and 200k characters consistently. I thought maybe it was a size issue but my server is receiving the images and decoding them and everything just fine. </p> <pre><code> public void Sharing() { pd = ProgressDialog.show(getParent(), null, "Please Wait..."); final String caption = mEtMessage.getText().toString(); RequestQueue queue = Volley.newRequestQueue(this); String url = "http://domain.com/ajax_ws.php"; StringRequest postRequest = new StringRequest( Request.Method.POST, url, new MyStringListener(), new MyErrorListener() ) { @Override protected Map&lt;String, String&gt; getParams() { Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;(); params.put("token", "secretToken"); params.put("mode", "createVoucher"); params.put("user_id", ActivityLogin.id); params.put("deal_id", ActivitySharing.id_deal); params.put("user_id_company", ActivityRestaurantDetails.res.getId()); params.put("user_img", pathImage); params.put("caption", caption); params.put("company_id", ActivityRestaurantDetails.res.getId()); return params; } }; queue.add(postRequest); } </code></pre> <p>Any idea why this might be happening?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload