Android Open Source - cellar-communicator Dump J S O N






From Project

Back to project page cellar-communicator.

License

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.

Java Source Code

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;
  }
  
}




Java Source Code List

com.vinit.orderplacer.CategoryList.java
com.vinit.orderplacer.CheckPin.java
com.vinit.orderplacer.CommentBox.java
com.vinit.orderplacer.CounterOnClickListener.java
com.vinit.orderplacer.DumpJSON.java
com.vinit.orderplacer.IPGetter.java
com.vinit.orderplacer.RetrieveJSON.java
com.vinit.orderplacer.RetrieveSalesmen.java
com.vinit.orderplacer.SalesApp.java
com.vinit.orderplacer.SalesHistory.java
com.vinit.orderplacer.Salesman.java
com.vinit.orderplacer.SecurityPIN.java
com.vinit.orderplacer.SummaryActivity.java