- private
- Thread submitThread =
- new Thread() {
- public void run() {
- HttpURLConnection connection
- =
- null;
- try {
- URL url
- =
- new
- URL(serviceURL+
- "SaveTestResult?bc="
- +bc+
- ");
- connection
- =
- (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setRequestProperty("Charset"
- ,
- "UTF-8");
- connection.setRequestProperty("Content-Type"
- ,
- "text/xml; charset=UTF-8");
- if
- (connection.getResponseCode() ==
- 200) {
- InputStream is
- =
- connection.getInputStream();
- result
- = ServiceHelper.convertStreamToString(
- is);
- Message msg
- =
- Message.obtain();
- msg.what
- =
- 0;
- subitHandler.sendMessage(msg);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- finally {
- if
- (connection !=
- null) {
- connection.disconnect();
- }
- }
- }
- };
- private
- Handler subitHandler =
- new Handler() {
- public void handleMessage(android.os.Message msg) {
- if
- (msg.what ==
- 0 ) {
- Toast.makeText(ViewTest.this
- ,
- "提交成功,下一个", Toast.LENGTH_SHORT).show();
- }
- }
- };
来源: http://www.bubuko.com/infodetail-2156427.html