blob: 84ab633acf230c607393f13308cdae02fc6a10c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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;
}
}
|