I need to capture an image from the camera and I need to do it from inside a Fragment. My problem is that onActivityResult is never called. Below is my code:
private void dispatchTakePictureIntent(){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
im.setImageBitmap(imageBitmap);
}
Log.e(TAG,"hello");
super.onActivityResult(requestCode, resultCode, data);
}
I have looked up several threads here on this forum but none of them are working for me.
Check if you aren't overwriting onActivityResult
in your Activity. If so you should call super.onActivityResult
from this method. Follow this question to find out the details: onActivityResult is not being called in Fragment