Android : how to be sure that image is ready to use

on Monday, October 13, 2014


i want to create a thumbnail after i took a picture but sometimes the image isn't finished yet and then i get a nullpointer exception



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
//Bitmap bitmp = (Bitmap) data.getExtras().get("data");
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = false;

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

// Bitmap btmp = Bitmap.createScaledBitmap(bmp, bmp.getWidth()/12, bmp.getHeight()/12, true);

Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions);

CommentDialog(bmp);
}

}


is there a way to check if image finished?


0 comments:

Post a Comment