Reputation: 25120
I've start activity using startActivityForResult. Inside started activity I want to finish calling activity using finishActivityFromChild. However it doesn't work. May be there is other method for this.
Upvotes: 2
Views: 1215
Reputation: 28439
If you startActivityForResult then what would the result go to if you killed the parent activity? It might be easier to simply lock out the back-button in your child activity, so that the user would have to start the app over to get back to it. There's probably some (very unrecommended) way to get a reference to your parent activity and store it in the Application and do it that way, if you REALLY had to, but I'm sure everyone and their mother will tell you that's a terrible idea.
Upvotes: 0
Reputation: 465
Is there a reason for killing the parent activity inside the child activity? Did you just want to kill the parent immediately after starting the child? I'm not seeing the point of using startActivityForResult() if the parent activity isn't using a result returned from the child activity, and is just getting killed by the child activity.
If you simply don't need the parent activity to exist after starting a new activity, you can use the following code:
Intent intent = new Intent(this, MyNextActivity.class);
startActivity(intent);
finish();
If you wanted to actually return a result to the parent activity from the child activity, and then finish the parent activity, you would have to return to the parent activity by finishing the child activity in order for onActivityResult() inside the parent activity to be run. If the child activity needs to return a result for processing something it cannot do by itself, you may need a Service to handle it instead.
Upvotes: 2