1

I'm having difficulties in achieving something that is important for my application and it's managing onActivityResult.

For example i have 3 activities.

Activity A which needs to get callback from other two activities and which runs method startActivityForResult()

Activity B which needs to return some value to Activity A, but also in some case needs to start Activity C and finish also.

Activity C is called from Activity B, but i need to return values to Activity A

So my question is, is it possible somehow to startActivityForResult() from Activity B, and it refers on Activity A, or any other suggestion would be good.

1 Answer 1

1

You can do the following:

  • A calls B via startActivityForResult().
  • B does its work. When it's done are 2 possibilities:
    1. B finishes its work and sends its result to A by calling setResult() and finish()
    2. B calls startActivityForResult() on C.
  • Now when C is done, you send your result to B by calling setResult() and finish().
  • B gets the result in its onActivityResult() and can now pass it to A by calling again setResult() and finish().

I hope this was understandable. If you need further clarification, please comment.

Sign up to request clarification or add additional context in comments.

2 Comments

I guess i would need to escape finishing Activity B when i'm calling startActivityForResult() on Activity C?
No, actually you are just sending your result back. When you're done in C, you can send the result to B and from there send it to A.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.