求助webservice上传图片,进度条的问题
求助,现在有做一个拍照之后上传图片到webservice的功能,用AsyncTask 在doInBackground方法里做图片上传的处理
onProgressUpdate里更新进度条
在调用transport.call(soapAction, envelope);方法时,不知道如何获取上传的具体进度
所以我在call方法后再读取文件大小来publishProgress更新进度条
我感觉这个做法是不对的
所以想请教各位,如何在上传图片到webservice的时候,监听具体发送了多少数据过去?这样才能具体的更新进度条
请各位解答
现在的代码如下:
HttpTransportSE transport = new HttpTransportSE(endPoint,10000);
transport.call(soapAction, envelope);
FileInputStream fis = new FileInputStream(Environment.getExternalStorageDirectory()+"/image.jpg");
long fileLength = fis.available();
int numRead = -1;
byte buf[] = new byte[1024];
float downloadSize = 0;
while((numRead = fis.read(buf)) != -1)
{
downloadSize += numRead;
progress = (int)(downloadSize*100/fileLength);
publishProgress(progress);
}
我无法读取到现在已经上传的大小
transport.getServiceConnection().openInputStream().read(buf) 会报错
所以我只能读当前文件大小 我应该怎么写才能得到已上传数据的大小?
补充:移动开发 , Android