これらの例外がユーザーから多く発生しています。java.lang.OutOfMemoryError:ビットマップサイズがVM予算を超えていますが、エミュレータで問題を再現できません。OutOfMemory URLから画像をデコードするとき
私はこれを私のImageDownloader http://code.google.com/p/android-imagedownloader/source/browse/trunk/src/com/example/android/imagedownloader/ImageDownloader.java#185として使用しています。画像をデコードしようとすると、問題は185行目で発生します。
このエラーに関して、stackoverflowには他にも多くの質問がありますが、私の具体的なケースに合った質問はありません。この質問の解決策は動作する可能性があります:https://stackoverflow.com/a/823966しかし、私はそれを動作させるように見えることはできません。ここで
は私ImageDownloaderに変更するものである:decodeStream()二回目の呼び出し時
final HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream inputStream = null;
try {
inputStream = entity.getContent();
// return BitmapFactory.decodeStream(inputStream);
// Bug on slow connections, fixed in future release.
FlushedInputStream flushedStream = new FlushedInputStream(inputStream);
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(flushedStream, null, o);
Log.d(LOG_TAG, "decodeStream - outWidth=" + o.outWidth + " outHeight=" + o.outHeight);
// The new size we want to scale to
final int REQUIRED_SIZE = 70;
// Find the correct scale value. It should be the power of
// 2.
int scale = 1;
while (o.outWidth/scale/2 >= REQUIRED_SIZE && o.outHeight/scale/2 >= REQUIRED_SIZE)
scale *= 2;
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeStream(flushedStream, null, o2);
} finally {
if (inputStream != null) {
inputStream.close();
}
entity.consumeContent();
}
}
それが失敗しました。エラーはSkImageDecoder :: Factoryはヌルを返しました。私はおそらくinputStreamが閉じられているか、2番目の呼び出しで利用できないと考えたので、上記の最初の行でBufferedHttpEntityを使用しようとしましたが、運がありません。
誰かが私を正しい方向に導くことができますか?ありがとう。
Googleでは、あなたの問題に関して多くの回答があります:) – RobinHood