diff options
author | AndrewMurrell <amurrel@purdue.edu> | 2014-05-07 15:11:26 -0400 |
---|---|---|
committer | AndrewMurrell <amurrel@purdue.edu> | 2014-05-07 15:11:26 -0400 |
commit | 3f676d37ad2a110eff5696791478c873be7b24ff (patch) | |
tree | 66d32b6c845054e70dbf8f83a94992665efcb4f6 | |
parent | f8b5fdbe0c835d599497f75e6cc7d56730057b49 (diff) |
Added PostTask
-rw-r--r-- | src/us/minak/PostTask.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/us/minak/PostTask.java b/src/us/minak/PostTask.java new file mode 100644 index 0000000..84ab633 --- /dev/null +++ b/src/us/minak/PostTask.java @@ -0,0 +1,54 @@ +package us.minak; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.FileEntity; +import org.apache.http.impl.client.DefaultHttpClient; + +import android.app.Activity; +import android.os.AsyncTask; +import android.widget.Toast; + +class PostTask extends AsyncTask<String, String, String>{ + + private SettingsActivity mThis; + + @Override + protected String doInBackground(String... uri) { + HttpClient httpclient = new DefaultHttpClient(); + HttpPost httppost = new HttpPost("https://lukeshu.com/minak-server"); + HttpResponse response = null; + try { + //FileInputStream stream = new FileInputStream(SettingsUtil.getGestureFile(this)); + httppost.setEntity(new FileEntity(SettingsUtil.getGestureFile(mThis), "application/octet-stream")); + response = httpclient.execute(httppost); + + Toast toast = Toast.makeText(mThis, response.toString(), Toast.LENGTH_LONG); + toast.show(); + } catch (ClientProtocolException e) { + // TODO Auto-generated catch block + } catch (IOException e) { + // TODO Auto-generated catch block + } + if (response != null){ + return response.toString(); + } else { + return ""; + } + } + + @Override + protected void onPostExecute(String result) { + //Do anything with response.. + ; + } + + public void setActivity(Activity ack) { + mThis = (SettingsActivity) ack; + } + +}
\ No newline at end of file |