Blame | Last modification | View Log | RSS feed
package com.saholic.profittill.Services;import android.util.Base64;import org.apache.http.HttpResponse;import org.apache.http.NameValuePair;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.HttpClient;import org.apache.http.client.entity.UrlEncodedFormEntity;import org.apache.http.client.methods.HttpPost;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.message.BasicNameValuePair;import org.json.JSONObject;import java.io.IOException;import java.util.ArrayList;public class PushDataRunnable implements Runnable {String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);String url;private JSONObject obj;public PushDataRunnable(JSONObject obj, String url){this.obj = obj;this.url = url;}@Overridepublic void run() {HttpClient httpclient = new DefaultHttpClient();try {ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();nameValuePairs.add(new BasicNameValuePair("pushdata",obj.toString()));HttpPost httppost = new HttpPost(url);httppost.setHeader("Authorization", basicAuth);httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));HttpResponse response = httpclient.execute(httppost);} catch (ClientProtocolException e) {} catch (IOException e) {}}}