我试图从http响应中获取图像,但无法将流转换为位图.请让我知道,我在这里失踪了什么.
仅供参考 - 图像内容作为原始二进制文件及其jpeg图像接收.
程序如下:
在postExecute的AsyncTask中执行此操作
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(endpoint);
// Adding Headers ..
// Execute the request
HttpResponse response;
try {
response = httpclient.execute(httpget);
if (response.getStatusLine().getStatusCode() == 200) {
// Get hold of the response entity
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
return instream;
// instream.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在postExecute的AsyncTask中执行此操作
if (null != instream) {
Bitmap bm = BitmapFactory.decodeStream(instream);
if(null …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个自定义对象从一个活动发送到另一个活动,但是当我调用start活动时它会崩溃.
以下是我使用的代码段.
我的活动实现了 Serializable
ArrayList<CUSTOM_OBJECT> Cus_Obje_arraylist = new ArrayList<CUSTOM_OBJECT>();
Run Code Online (Sandbox Code Playgroud)
这是我的意图:
Intent inte = new Intent(getApplicationContext(), ListActivity.class); `
inte.putExtra("list",Cus_Obje_arraylist);`
startActivity(inte);
Run Code Online (Sandbox Code Playgroud)
请让我知道为什么它会崩溃或我可以使用什么替代方式?