Wednesday, 18 September 2013

OutOfMemory Android Error

OutOfMemory Android Error

I have a camera application that I'm trying to make and I've just started,
but I keep running into an error when I try to take the second picture. Am
I not recycling the bitmap properly?
private PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
capture.setVisibility(View.INVISIBLE); //hide on screen icons
photo = BitmapFactory.decodeByteArray(data, 0, data.length);
Toast.makeText(getApplicationContext(), "Picture Size: " +
photo.getWidth() + " x " + photo.getHeight(),
Toast.LENGTH_SHORT).show();
//show ScrollView with options
dialog.setContentView(R.layout.dialog_preview);
dialog.setCancelable(true);
dialog.show();
//final ImageView preview =
(ImageView)dialog.findViewById(R.id.preview);
//preview.setImageBitmap(photo);
dialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
Toast.makeText(context, "Dialog was canceled",
Toast.LENGTH_SHORT).show();
//photo = null;
photo.recycle();
capture.setVisibility(View.VISIBLE); //show on screen
icons
mCamera.startPreview(); //resume preview
dialog.cancel();
}
});
}
}; //end PictureCallback

No comments:

Post a Comment