0

This works perfectly fine i can click image from my camera and update my image view with it but i don't know how this method is working. what things are passed to onActivityResult().

private void pickFromCamera() {
        
        ContentValues values=new ContentValues();
        values.put(MediaStore.Images.Media.TITLE,"Temp pic");
        values.put(MediaStore.Images.Media.DESCRIPTION,"Temp Description");

        
        image_uri=getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);

        
        Intent cameraIntent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// intent to open camera
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,image_uri);//putting image uri into this
         startActivityForResult(cameraIntent,IMAGE_PICK_CAMERA_CODE);

    }

1 Answers1

0

When we start another activity from the current activity to get the result for it, we call the method startActivityForResult(intent, RESPONSE_CODE);. It redirects to another activity like opens camera, gallery, etc. After taking an image from the gallery or camera then come back to the current activity first method that calls is onActivityResult(int requestCode, int resultCode, Intent data). We get the result in this method like the taken image from camera or gallery.