字节数组有效,因为响应正在运行iOS设备。 我无法转换它,因为Bitmap总是为空。
Bitmap bitmap = BitmapFactory.decodeByteArray(response, 0, response.length);
字节数组长度 - 86842
我检查了其他答案,但都指向无效的字节数组。我的不是。
InputStreamRequest api = new InputStreamRequest(Request.Method.POST, imageURL, new Response.Listener<byte[]>()
{
@Override
public void onResponse(byte[] response)
{
Log.e( TAG ,"imageURL response : " + response );
dismissCustomDialog();
try
{
BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeByteArray(response, 0, response.length, options );
Log.e( TAG ,"Length : " + response.length );
Log.e( TAG ,"Bitmap : " + bitmap );
imageView.setImageBitmap( bitmap );
}
catch( Exception e)
{
Log.e( TAG , "image exc. " + e.toString() );
}
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
dismissCustomDialog();
tv_error.setVisibility(View.VISIBLE);
}
});
RequestQueue volleyQueue = Volley.newRequestQueue( context);
volleyQueue.add(api);