Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android closing child activity from parent activity

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?

like image 599
nilkash Avatar asked Mar 27 '13 08:03

nilkash


2 Answers

You can start activity B by using startActivityForResult (Intent intent, int requestCode) then you can close activity B by calling finishActivity (int requestCode).

like image 65
Hoan Nguyen Avatar answered Sep 18 '22 16:09

Hoan Nguyen


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

like image 25
Damien R. Avatar answered Sep 19 '22 16:09

Damien R.