我有一个代码开始意图从相机拍照
Intent pictureActionIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(pictureActionIntent, PhotoUtility.CAMERA_PICTURE);
图片收回后应调用onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != Activity.RESULT_OK)
return;
if (requestCode == PhotoUtility.CAMERA_PICTURE) {
File f = PhotoUtility.saveFromCamera(data, picIV);
imagePath = f.getAbsolutePath();
} else if (requestCode == PhotoUtility.GALLERY_PICTURE) {
File f = PhotoUtility.saveFromGallery(data, getActivity(), picIV);
imagePath = f.getAbsolutePath();
}
}
使用简单Fragment
它可以正常工作,但如果我使用DialogFragment
onActivityResult
则不会调用。如何使用DialogFragment
解决此问题?