I want to display an image taken from the camera in an ImageView using
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
You can use the solution of AnujMathur_07, but if you do not want work with paths and files, in the method onPictureTaken
, you can return the bitmap:
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Toast.makeText(getApplicationContext(), "Picture Taken",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
Bitmap bmp = BitmapFactory.decodeByteArray(data, 0,
data.length);
intent.putExtra("image", bmp);
setResult(RESULT_OK, intent);
camera.stopPreview();
if (camera != null) {
camera.release();
mCamera = null;
}
finish();
}
And in the method onActivityResult
you can get bitmap:
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("image");