0

I have a problem with onActionResult inside the class which subclassed of the DialogFragment. The onActionResult not get called but it call the Activity who start the DialogFragment.

The calling is this AppCompatActivity A -> DialogFragment -> AppCompatActivity B Expected result is AppCompatActivity B send result back to DialogFragment.

I have the same process as above but instead AppCompatActivity A, it was Fragment and that part work.

This is my code below to show DialogFragment:

if (getContext() instanceof AppCompatActivity) {
        FragmentManager manager = ((AppCompatActivity) getContext()).getSupportFragmentManager();
        AttachmentOptionDialog imgAttachment = AttachmentOptionDialog.newInstance(dialogListener);
        imgAttachment.setTargetFragment(imgAttachment, MobileConstant.newInstance().REQUEST_CODE_PROFILE_PHOTO);
        imgAttachment.show(manager, "");
    }

Calling the Activity B:

v.setEnabled(false);
            Intent intent = new Intent();
            intent.setClass(getActivity(), CameraActivity.class);
            startActivityForResult(intent, MobileConstant.newInstance().REQUEST_CODE_CAMERA);
LittleFunny
  • 8,155
  • 15
  • 87
  • 198
  • Possible duplicate of [onActivityResult not being called in Fragment](http://stackoverflow.com/questions/6147884/onactivityresult-not-being-called-in-fragment) – mikejonesguy Oct 22 '15 at 03:57

1 Answers1

0

Try this in DialogFragment:-

Intent intent = new Intent(getActivity(), CameraActivity.class);
startActivityForResult(intent,MobileConstant.newInstance().REQUEST_CODE_CAMERA);    

And to get result in DialogFragment you need to override the activity's onActivityResult() like this :-

@Override
     public void onActivityResult(int requestCode, int resultCode, Intent   data) {
         if(resultCode == MobileConstant.newInstance().REQUEST_CODE_CAMERA){
          //Write Your Code Here To Be Performed After Getting Result
         }
     }
Nijraj Gelani
  • 1,446
  • 18
  • 29