下面android代码是上传的照片,现在要求上传完后吧照片从相册里删掉,怎么做? private void doSubmitUpload_W() { Map<String, Object> uploadparams = null; try { if ((mPgDialog != null) && mPgDialog.isShowing()) { mPgDialog.dismiss(); } mPgDialog = createPhotoDialog_W(R.string.photo_uploading_and_wait); mPgDialog.show(); uploadCallback_w = new AjaxCallback<JSONObject>() { @Override public void callback(String url, JSONObject json, AjaxStatus status) { if ((mPgDialog != null) && mPgDialog.isShowing()) { TakeTxPhotoActivity.this.mPgDialog.dismiss(); } // 解析结果 TakeTxPhotoActivity.this.parseUploadResult_w(url, json, status); } }; Long staffId = SessionManager.getInstance().getStaffId() == null?-1L:SessionManager.getInstance().getStaffId(); uploadparams = new HashMap<String, Object>();// ParamHelper.buildJSONParam(URLs.UPLOADFILE_API,json); byte[] photots = Bitmap2Bytes(ImageUtils.getBitmapByPath(mWorkAdapter.get( curPhotoPos_W).getThumbnailPath())); uploadparams.put("photoFile2",photots); uploadparams.put("StaffId", staffId); uploadparams.put("StaffName", session.getStaffInfo().getStaffName()); uploadparams.put("OrderID", orderId); uploadparams.put("WorkOrderID", workOrderId); uploadparams.put("TypeName", "WORK"); uploadparams.put("photosType", mWorkAdapter.get(curPhotoPos_W).getPhotosType()); Log.e(TAG, "请求参数json:" + uploadparams.toString()); // 异步网络请求 aQuery.ajax(BaseURLs.UPLOAD_KT_PHOTO, uploadparams, JSONObject.class, uploadCallback_w); } catch (Exception ex) { AlertUtils.showAlert(TakeTxPhotoActivity.this, R.string.opt_prompt, R.string.unknown_error); ex.printStackTrace(); } }
时间: 2024-04-10 12:27:01 浏览: 137
我的照片上传会删除的
您可以在上传照片的回调方法中添加删除照片的逻辑。在`callback`方法中,您可以使用以下代码删除照片:
```java
File photoFile = new File(mWorkAdapter.get(curPhotoPos_W).getThumbnailPath());
boolean deleted = photoFile.delete();
if (deleted) {
Log.e(TAG, "照片删除成功");
} else {
Log.e(TAG, "照片删除失败");
}
```
将上面的代码添加到`callback`方法的开始部分,即可在上传完毕后删除照片。请确保`mWorkAdapter.get(curPhotoPos_W).getThumbnailPath()`返回的是照片文件的路径。
阅读全文