【发布时间】:2014-12-30 10:56:49
【问题描述】:
我正在尝试使用 android 异步 http 客户端将图像从 drawable 发送到 rest web 服务。此链接显示如何发送图像使用路径,
是否可以从drawable发送图像?我已经从Android Asynchronous Http Client 中查看了有关如何发送字节图像的信息,但是在我的代码中,它一直返回图片丢失的错误。这是我的代码
RequestParams params = new RequestParams();
username = editTextEmail.getText().toString();
name = editTextName.getText().toString();
password = editTextPassword.getText().toString();
phone = editTextPhone.getText().toString();
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.ic_user);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, stream);
imageInByte = stream.toByteArray();
if(isOnline()){
params.put("email", username);
params.put("name", name);
params.put("password", password);
params.put("phone", phone);
params.put("picture", new ByteArrayInputStream(imageInByte), "user.jpg");
invokeWS(params);
return true;
}
谁能帮帮我?谢谢之前
【问题讨论】:
标签: android image asynchronous loopj