Note that there are some explanatory texts on larger screens.

plurals
  1. POSending the data to the server through post when internet connection comes back
    text
    copied!<p>In my application, i am sending the data to the server through post method in json format. Here you can see my code.</p> <pre><code>JSONObject object1 = new JSONObject(); object1.put("homesafe_events_version", "1.0"); JSONObject object = new JSONObject(); object.put("PhoneNumber", phoneNumber); object.put("EventTypeID", Integer.parseInt(eventTypeId)); object.put("FreeFromText", ""); object.put("EventTime", eventTime ); object.put("Latitude", latitude); object.put("Longitude", longitude); object.put("Altitude", Double.parseDouble(df.format(altitude))); object.put("HorizAccuracy",Double.parseDouble(df.format(horizAccuracy))); object.put("VertAccuracy", vertiAccuracy); object.put("Speed", speed); object.put("Heading", Double.parseDouble(df.format(heading))); object.put("BatteryStatus", batteryStatus); object1.put("Event", object); String str = object1.toString(); HttpClient client = new DefaultHttpClient(); String encodedURL = URLEncoder.encode(str, "UTF-8"); HttpPost request = new HttpPost(url); List&lt;NameValuePair&gt; value = new ArrayList&lt;NameValuePair&gt;(); value.add(new BasicNameValuePair("Name", encodedURL)); // UrlEncodedFormEntity entity=new UrlEncodedFormEntity(value); StringEntity entity = new StringEntity(str, "UTF8"); request.setHeader("Content-Type", "application/json"); request.setEntity(entity); HttpResponse response = client.execute(request); HttpEntity resEntity = response.getEntity(); response_str = EntityUtils.toString(resEntity); </code></pre> <p>Every thing is working properly.There is a button in my app.On clicking that button,some values are calculated and pass in the parameters to send them to server.Now suppose the internet is not available and i pressed that button for 5 times then in this case all the values which was calculated 5 times are stored in somewhere else and when the connection comes the web service will hit and all the data will be sent to the server.This is my actual problem.Please suggest me what to do.Thanks in Advance !! </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