1

I am working on a fragment that call camera.

startActivityForResult(intent, REQUEST_CAMERA);

The problem is , if I overwrite the onActivityResult inside the fragment, it does not call,

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d("test","result frag");

        super.onActivityResult(requestCode, resultCode, data);
    }

but only call the onActivityResult in Main Activity

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
   Log.d("test","main");
   super.onActivityResult(requestCode, resultCode, data);
}

After some findings, there is some solution by calling the fragment method inside the Main Activity 's onActivityResult function. But how can I fix it with other approach? Thanks a lot.

user782104
  • 13,233
  • 55
  • 172
  • 312
  • possible duplicate of [onActivityResult not being called in Fragment](http://stackoverflow.com/questions/6147884/onactivityresult-not-being-called-in-fragment) – Pedro Oliveira Feb 06 '15 at 10:09
  • Thanks for remind, the problem is I already use startActivityForResult(intent,111) in fragment instead of getActivity().startActivityForResult(intent,111) , but still can not call. – user782104 Feb 06 '15 at 10:10
  • Check the other answers too. For some reason there are 11 answers with at least one upvote. – Pedro Oliveira Feb 06 '15 at 10:12
  • yes I found in that post almost all use fragment.startActivityForResult apporach, I would like to find any other workaround. Sorry for that if it duplicate from others. – user782104 Feb 06 '15 at 10:17
  • You need to check the whole post. There are simple things like the activity's launch mode and history and such... :) – Pedro Oliveira Feb 06 '15 at 10:18
  • 1
    Important --> Fragment is a child of an Activity, – Bhavik Mehta Feb 06 '15 at 10:53

1 Answers1

0

remove super.onActivityResult(requestCode, resultCode, data); in your fragment.

quang dung
  • 73
  • 2
  • 7