新聞の画像(epaper)をギャラリービューで表示する必要があるため、新聞アプリを作成しています...約100枚の画像をダウンロードする必要があります。そのためにasyncTaskを使用し、ダウンロード画像ごとに新しいAsyncTaskオブジェクトを作成します。画像をダウンロードしてギャラリーに設定しようとすると、「VMでは割り当てができません...バイト」というエラーが発生し、クラッシュします。アプリ。
new AsyncTask<String, Void, Bitmap> () {
@Override
protected Bitmap doInBackground(String... params) {
HttpGet httpRequest;
try {
httpRequest = new HttpGet(new URL(params[0]).toURI());
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpClient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream is = bufHttpEntity.getContent();
return BitmapFactory.decodeStream(is);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}/* catch (Error e) {
e.printStackTrace();
}*/
return null;
}
@Override
protected void onPostExecute(Bitmap result) {
if(result != null) {
img.setImageBitmap(ePaperInfo.getImgJpg1());
notifyDataSetChanged();
}
}
}
logcatにエラーを表示します。
私を助けてください
前もって感謝します。