Reputation: 497
I launch activity A from activity B . But as I launch A , B gets Destroyed. As a result A gets displayed momentarily and then gets destroyed . How do i keep A alive even after B is destroyed. This is how i launch A from B.
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setClass(B.this, A.class);
intent.putExtra(key, val);
startActivity(intent);
I have mentioned the launchmode for Activity A in the manifest file as 'singleTask'.
Please help me how to achieve this .
Upvotes: 1
Views: 578
Reputation: 1215
Actvity B is destroyed due to the flag Intent.FLAG_ACTIVITY_CLEAR_TOP
, but doesnt affect activity A life cycle. Meaning that if Activity A its being destroyed it might be some error in its own life cycle method but its not chained to Activity B
Upvotes: 1