I'm trying to do an app (with the master/detail flow template) that in the detail fragment, has an ImageView that shows an image taken by the camera.
For this option, I added a button to the ActionBar that opens a Dialog box and asks the user if he wishes to add an image with the camera. So for this option I made this two methods that are called when the user clicks ok. However, (here I now I'm making huge mistakes) I don't have the least idea about how to call the onActivityResult() with the end of having my ImageIcon showing the thumbnail retrieved from the camera. (as developer.android tutorial shows)
If anyone of you guys knows what I am doing wrong, I would be really happy to hear all the solutions that you can give me, since I wasn't able to find a solution to this problem anywhere.
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
onActivityResult(REQUEST_IMAGE_CAPTURE, RESULT_OK, takePictureIntent);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
ImageView mImageView = (ImageView) findViewById(R.id.imageView1);
mImageView.setImageBitmap(imageBitmap);
}
}
THANKS A LOT!!!!