Reputation: 7536
I wanted to close child activity from parent activity. My flow is like: activity A is opened, inside Activity A I am opening activity B. But at same time my activity A is doing some background task. When I got result of my background task I wanted to close activity B from Activity A.
Is it possible to do that?
Upvotes: 14
Views: 9117
Reputation: 3373
What you should do is start your activity with startActivityForResult(yourIntent, childId);
Then, when you want to kill your child activity, try finishActivity(childId);
Saw that Here
Upvotes: 6
Reputation: 567
you don't need to finish() every activity once you leave it, Android will do that for you. so you just restart Activity A to the top task .
Upvotes: 1
Reputation: 18151
You can start activity B by using startActivityForResult (Intent intent, int requestCode)
then you can close activity B by calling finishActivity (int requestCode)
.
Upvotes: 29