title: Take photo from camera in fragment
body: <p>In my <code>Fragment</code> I try to take picture from my camera but the <code>onActivityResult</code> of my <code>Fragment</code> is not called. After taking photo this <code>Fragment</code> is not showing and is switching to my first <code>Fragment</code>. In there any other way for capturing photos in a <code>Fragment</code>, or what am I doing wrong?</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>public void takePhoto() {
          Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
          File photo = new File(Environment.getExternalStorageDirectory(),  "Pic.jpg");
          intent.putExtra(MediaStore.EXTRA_OUTPUT,
                  Uri.fromFile(photo));
          imageUri = Uri.fromFile(photo);
          PhotosListFragment.this.startActivityForResult(intent, 100);
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          switch (requestCode) {
          case 100:
              if (resultCode == Activity.RESULT_OK) {
                  Uri selectedImage = imageUri;
                  getActivity().getContentResolver().notifyChange(selectedImage, null);
                  ContentResolver cr = getActivity().getContentResolver();
                  Bitmap bitmap;
                  try {
                       bitmap = android.provider.MediaStore.Images.Media
                       .getBitmap(cr, selectedImage);
  
                      viewHolder.imageView.setImageBitmap(bitmap);
                      Toast.makeText(getActivity(), selectedImage.toString(),
                              Toast.LENGTH_LONG).show();
                  } catch (Exception e) {
                      Toast.makeText(getActivity(), "Failed to load", Toast.LENGTH_SHORT)
                              .show();
                      Log.e("Camera", e.toString());
                  }
              }
          }
      }
  </code></pre>