I am trying to decode a byte array. The decodeByteArray returns NULL sometimes and sometimes it returns bitmap for the same image. I am calling this inside doInBackground. This is what I am doing:
public static Bitmap decodeSampledBitmapFromResource(byte[] data,
int reqWidth, int reqHeight) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, options);
options.inScaled = true;
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
options.inJustDecodeBounds = false;
Bitmap bmpOriginal = BitmapFactory.decodeByteArray(data, 0, data.length, options);
return toGrayScale(bmpOriginal);
}
This behavior seems to be happening only on certain phones.