@Override protected Boolean doInBackground(Void... params) { boolean success = false; SoapService soapService = new SoapService(); soapService.setUtils( Common.getSERVER_ADDRESS() + Common.CAR_CHECK_SERVICE, Common.UPLOAD_PICTURE); for (int i = 0; i < photoEntityList.size(); i++) { if (isCancelled()) { break; } PhotoEntity photoEntity = photoEntityList.get(i); // 获取照片的物理路径 Bitmap bitmap; String fileName = photoEntity.getFileName(); if (photoEntity.getModifyAction().equals(Action.DELETE) || photoEntity.getModifyAction().equals(Action.COMMENT)) { fileName = ""; } Log.d(Common.TAG, "正在上传..."); Log.d(Common.TAG, photoEntity.getJsonString()); // 如果照片名为空串,表示要上传空照片 if (fileName.equals("")) { success = soapService.uploadPicture(photoEntity.getJsonString()); } else { bitmap = BitmapFactory.decodeFile(path + fileName); success = soapService.uploadPicture(bitmap, photoEntity.getJsonString()); } if (success) { // 如果成功上传,推动进度条 Log.d(Common.TAG, "上传成功!"); publishProgress(i + 1); } else { i--; } } return success; }