5 |
import java.util.ArrayList; |
import java.util.ArrayList; |
6 |
import java.util.List; |
import java.util.List; |
7 |
|
|
8 |
|
import org.apache.http.HttpResponse; |
9 |
import org.apache.http.NameValuePair; |
import org.apache.http.NameValuePair; |
10 |
import org.apache.http.client.HttpClient; |
import org.apache.http.client.HttpClient; |
11 |
import org.apache.http.client.methods.HttpPost; |
import org.apache.http.client.methods.HttpPost; |
139 |
|
|
140 |
|
|
141 |
post.setEntity(entity); |
post.setEntity(entity); |
142 |
|
boolean ok = false; |
143 |
HttpClient client = new DefaultHttpClient(); |
HttpClient client = new DefaultHttpClient(); |
144 |
try { |
try { |
145 |
client.execute(post); |
HttpResponse resp = client.execute(post); |
146 |
Toast.makeText(this, "Upload succeeded", Toast.LENGTH_LONG).show(); |
if (resp.getStatusLine().getStatusCode() == 200) { |
147 |
|
ok = true; |
148 |
|
} |
149 |
|
|
150 |
} catch (Exception e) { |
} catch (Exception e) { |
151 |
Log.d("PostActivity", "upload failed", e); |
Log.d("PostActivity", "upload failed", e); |
152 |
|
|
153 |
|
} |
154 |
|
if (ok == true) { |
155 |
|
Toast.makeText(this, "Upload succeeded", Toast.LENGTH_LONG).show(); |
156 |
|
} else { |
157 |
Toast.makeText(this, "Upload failed", Toast.LENGTH_LONG).show(); |
Toast.makeText(this, "Upload failed", Toast.LENGTH_LONG).show(); |
158 |
} |
} |
159 |
} |
} |