Search code examples
androidlayoutmobile-application

startActivityForResult and child activities


I'm really new to android programming, so I have a very basic and general question: Supppose I have three activities: Act1,Act2 and Act3. I would like Act1 to start Act2 that will start Act3 (Act1->Act2->Act3). Then, Act3 gets some info and sends it to Act2 which sends it back to Act1 (Act3->Act2->Act1) so altogether it's (Act1->Act2->Act3->Act2->Act1). When Act2 calls Act3 and gets the info back from it (Act2->Act3->Act2) startActivityForResult should be used, I guess, but when Act1 calls Act2, what should be used? maybe startActivity? The difference is that Act1 calls Act2 but then Act2 is paused ,because Act3 is started, instead of sending info immediately back to Act1. Can startActivityForResult handle such a case? What exactly happens to the parent activity while the child activity os running? I apologize if I was not clear enough... If needed, I can clarify some more... Thanks, J


Solution

  • When Act2 calls Act3 and gets the info back from it (Act2->Act3->Act2) startActivityForResult should be used, I guess, but when Act1 calls Act2, what should be used?

    Android will handle that. Just use startActivityForResult, it will work as expected - it will call onActivityResult on Act1 when Act2 is finished.