0

I completely tried solutions given on here

I have tried startActivityForResult and startIntentSenderForResult But it's not work for me.Honestly, I'm not sure to I get it. Simply I use this code my activity and works fine but it's not working on the fragment.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (!bp.handleActivityResult(requestCode, resultCode, data))
        super.onActivityResult(requestCode, resultCode, data);
}
Fábio Nascimento
  • 2,644
  • 1
  • 21
  • 27
Dorbagna
  • 307
  • 1
  • 4
  • 16
  • add onActivity result in activty of your fragment and pass it to your fragment .it will work – Atif AbbAsi Feb 22 '19 at 14:36
  • In which activty ? I use Tablayout and this is tab2 (fragment2) – Dorbagna Feb 22 '19 at 14:40
  • In activity where you are initializing your tabs add your activity and tab fragment code. – Atif AbbAsi Feb 22 '19 at 14:41
  • You have not shown the calling code, but ensure Fragment.startActivityForResult() is called not Activity.startActivityForResult(). – Elletlar Feb 22 '19 at 14:42
  • If you call `startActivityForResult` in fragment, you get the result in fragment. If you call it in activity (or from fragment but with `getActivity().startActivityFromResult`) you get the result in the activity. – Eugen Pechanec Feb 22 '19 at 14:55
  • Do I use something code as here https://stackoverflow.com/questions/44622311/how-can-i-call-onactivityresult-inside-fragment-and-how-it-work/44622456#44622456 on activty.Do I have to change anything on activty.Is it possiable to finish in fragment ? – Dorbagna Feb 22 '19 at 14:58

1 Answers1

0

Follow this question and read this answer answer1, answer2

I think when you add startActivityForResult, that time use context of getActivity().

Add getActivity().startActivityForResult();

Pranav P
  • 1,755
  • 19
  • 39