Tahir Ferli
Tahir Ferli

Reputation: 636

Intent is empty

I copied the codes from the android developer page. I read many posts here about onActivityResult is not triggered. None of the scenarios are working for me.

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");
        mImageView = (ImageView)findViewById(R.id.imageView);
        mImageView.setImageBitmap(imageBitmap);
    }
}
static final int REQUEST_TAKE_PHOTO = 1;

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
        }
        if (photoFile != null) {
            Uri photoURI = Uri.fromFile(photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }

Upvotes: 0

Views: 320

Answers (2)

Tahir Ferli
Tahir Ferli

Reputation: 636

When i write this;

takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);

onActivityResult()'s intent returns null. So, actually it is not about onActivityResult() not called. It is about the intent passed in onActivityResult returns null.

So, i just deleted putExtra() method, it works fine now.

Upvotes: 2

Related Questions