AsyncHttpClient这个框架有用过的吗,上传文件时如何获得进度
推荐于2016-09-24 · 知道合伙人数码行家
可以叫我表哥
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:25897
获赞数:1464978
2010年毕业于北京化工大学北方学院计算机科学与技术专业毕业,学士学位,工程电子技术行业4年从业经验。
向TA提问 私信TA
关注
展开全部
AreaHttpUtil.post(URL, params, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, JSONObject response) {
super.onSuccess(statusCode, response);
Toast.makeText(AreaApplication.context, "上传成功", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseBody, Throwable e) {
super.onFailure(statusCode, headers, responseBody, e);
Toast.makeText(AreaApplication.context, "上传失败", Toast.LENGTH_SHORT).show();
}
public void onProgress(int current, int count) {
System.out.println("current " + current);
System.out.println("total " + count);
upload.setProgress((int) (current / (float) count * 100));
upload.setText(current / 1024 + "/" + count / 1024 + "K");
Message message = new Message();
message.obj = upload;
message.what = 1;
GlobalHandler.getHandler().sendMessage(message);
}
});
@Override
public void onSuccess(int statusCode, JSONObject response) {
super.onSuccess(statusCode, response);
Toast.makeText(AreaApplication.context, "上传成功", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseBody, Throwable e) {
super.onFailure(statusCode, headers, responseBody, e);
Toast.makeText(AreaApplication.context, "上传失败", Toast.LENGTH_SHORT).show();
}
public void onProgress(int current, int count) {
System.out.println("current " + current);
System.out.println("total " + count);
upload.setProgress((int) (current / (float) count * 100));
upload.setText(current / 1024 + "/" + count / 1024 + "K");
Message message = new Message();
message.obj = upload;
message.what = 1;
GlobalHandler.getHandler().sendMessage(message);
}
});
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询