Android不要使用DialogFragment调用onActivityResult

时间:2014-09-02 13:04:58

标签: android onactivityresult dialogfragment

我有一个代码开始意图从相机拍照

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解决此问题?

0 个答案:

没有答案