Back to project page cellar-communicator.
The source code is released under:
GNU General Public License
If you think the Android project cellar-communicator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.vinit.orderplacer; //from w w w .ja v a 2 s .com import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.ProgressDialog; import android.os.AsyncTask; import android.util.Log; public class DumpJSON extends AsyncTask<Void, Void, Void> { String json; IPGetter ipg; public DumpJSON(String s, String salesman, String party, String comment) { try { JSONArray jArr = new JSONArray(s); JSONObject jObj = new JSONObject(); Log.i("DUMP", salesman); jObj.put("salesman", salesman); jObj.put("party", party); jObj.put("comment", comment); jArr.put(jObj); this.json = jArr.toString(); } catch(JSONException e) { e.printStackTrace(); } } @Override protected Void doInBackground(Void... arg0) { ipg = new IPGetter(); HttpClient httpClient = new DefaultHttpClient(new BasicHttpParams()); HttpPost httpPost = new HttpPost(ipg.getIP() + "db_post.php"); try { httpPost.setEntity(new StringEntity(json)); httpPost.setHeader("Content-Type", "application/json"); httpPost.setHeader("Accept-Encoding", "application/json"); httpPost.setHeader("Accept-Language", "en-US"); httpClient.execute(httpPost); } catch (Exception e) { e.printStackTrace(); } return null; } }