3

I am working on a very basic app which captures a photo using the phone's camera and sets it up on the ImageView. But the code is not entering the if(resultCode==Activity.RESULT_OK) statement. I understood this by using Log inside the if statement. Any idea how I can resolve this? Here is the onActivityResult()

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    if(resultCode==Activity.RESULT_OK){
        Log.v("cam"," resultCode");
        Bundle extras=data.getExtras();
        bmp=(Bitmap) extras.getParcelable("data");
        iv.setImageBitmap(bmp);
        button1.setText("Take Another");
    }
}
Prat
  • 67
  • 7

2 Answers2

0

first of all

  • Check that u have all the necessary permission in the manifest file for capturing the image and where you're storing that image that folder access.

Check it out for more reference. for reference

Nikit Dungrani
  • 185
  • 1
  • 7
-1

Try This ... It works for Me..

if ( resultCode == Activity.RESULT_OK ) {
        Uri path = data.getData();
        try {
            bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),path);
            imgView.setImageBitmap(bitmap);
            imgView.setVisibility(View.VISIBLE);
            Name.setVisibility(View.VISIBLE);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }