Call startIntentSenderForResult from a fragment (without using existing activity) (Android Billing v3)

In accordance with this question:

Call startIntentSenderForResult from a fragment (Android Billing v3)

The startIntentSenderForResult call requires you to pass an action that implements onActivityResult (...). Fragments cannot implement this, so if you want to call a method from one, you need to pass it through an Activity, presumably an Activity, creating a fragment.

My problem differs from the existing question in that I do not have an easily accessible Activity that I can implement onActivityResult. My fragment is created by another fragment, and there is a lot of logic and decoding of domain objects, etc., which occur between this fragment and the "main" activity that initiates the process.

So, for practical and architectural reasons, I would prefer not to pass the callback to this Activity and return to the calling fragment.

I am thinking of something like:

  • which makes the call, creates a temporary activity that contains a link to the fragment and implements onActivityResult, which processes the callback and redirects it back to the fragment.

Help of any kind would be greatly appreciated.

+4
1

Activity ( FragmentActivity source onActivityResult) onActivityResult 'onActivityResult Activity onActivityResult. onActivityResult .

. onActivityResult, , super.onActivityResult onActivityResult.

0

Source: https://habr.com/ru/post/1532080/


All Articles