I have a vehicle inspection application that is working, except on a Samsung Galaxy 4. Using a camera intent, the user takes a picture, selects ok, then onActivityResult, it crashes. As you can see, I am using iText to create a PDF later in the code, but I create the iText Image. Does anyone have a clue on this specific issue???
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
tireTreadImageView = (ImageView) findViewById(id.tire_tread_image);
insideVanCleanImageView = (ImageView) findViewById(id.inside_van_clean_image_view);
windshieldConditionImageView = (ImageView) findViewById(id.windshield_image_view);
Bitmap bitmap;
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
File f;
ByteArrayOutputStream bmpStream = new ByteArrayOutputStream();
if (resultCode == RESULT_OK) {
switch (requestCode) {
case TIRE_TREAD_CAMERA_INTENT:
f = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "temp_tire_tread.jpg");
bitmap = BitmapFactory.decodeFile(f.toString(), bitmapOptions);
//imageCaptured = (Bitmap) data.getExtras().get("data");
tireTreadImageView.setImageBitmap(bitmap);
tireTreadImage = bitmap;
tireTreadImage.compress(Bitmap.CompressFormat.JPEG, 15, bmpStream);
try {
tireTreadCellImage = Image.getInstance(bmpStream.toByteArray());
} catch (BadElementException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
break;
case VAN_CLEAN_CAMERA_INTENT:
f = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "temp_van_clean.jpg");
bitmap = BitmapFactory.decodeFile(f.toString(), bitmapOptions);
//imageCaptured = (Bitmap) data.getExtras().get("data");
insideVanCleanImageView.setImageBitmap(bitmap);
insideVanCleanImage = bitmap;
insideVanCleanImage.compress(Bitmap.CompressFormat.JPEG, 15, bmpStream);
try {
insideVanCleanCellImage = Image.getInstance(bmpStream.toByteArray());
} catch (BadElementException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
break;
case WINDSHIELD_CAMERA_INTENT:
f = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "temp_windshield.jpg");
bitmap = BitmapFactory.decodeFile(f.toString(), bitmapOptions);
//imageCaptured = (Bitmap) data.getExtras().get("data");
windshieldConditionImageView.setImageBitmap(bitmap);
windshieldImage = bitmap;
windshieldImage.compress(Bitmap.CompressFormat.JPEG, 15, bmpStream);
try {
windshieldConditionCellImage = Image.getInstance(bmpStream.toByteArray());
} catch (BadElementException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
bmpStream.reset();
}