Dusan Dimitrijevic
Dusan Dimitrijevic

Reputation: 3219

Manage startActivityForResult and onActivityResult

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.

Upvotes: 1

Views: 80

Answers (1)

techfly
techfly

Reputation: 1866

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.

Upvotes: 1

Related Questions