Eugene
Eugene

Reputation: 60184

How to keep always up-to-date reference to Activity

I have two Activities and I want to keep a reference of a second Activity in a first Activity. What would be the best way to keep the reference always up-to-date because as far as I understand new instance of an Activity is created each time the Activity is launching.

Upvotes: 0

Views: 224

Answers (2)

JQCorreia
JQCorreia

Reputation: 717

I'm not sure i follow the question, but anytime you launch an activity the other stays on the stack and you don't lose it.

Take a look at android:launchMode for a better explanation of this and the several options you have.

Hope I understood the question right!

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006869

I want to keep a reference of a second Activity in a first Activity.

You absolutely positively do NOT want to do this. Find another solution for whatever problem you think you are trying to solve.

To clarify, this will introduce memory leaks.

Upvotes: 3

Related Questions