Reputation: 19723
I have 2 Activities A and B. Now these are my objectives.
But in Step 2 the state of B still prevails. How do I accomplish my objective?
Upvotes: 1
Views: 435
Reputation: 10738
You don't even need to send a boolean like Scythe suggested. The Bundle savedInstanceState
will be null in onCreate
for Activity B if Activity A just started it, whereas it will be non-null if you are coming back from a saved state.
Upvotes: 1
Reputation: 3313
refer this url
Android; How can I initialise state in one activity, then have another refresh that?
Upvotes: 1
Reputation: 16914
I think one possible solution woudl be to pass some extra information inside the starting Intent, when you start Activity B from A (like a boolean value). And in the "onStart()" of B, you check if you can find this extra info in the intent (you get it with getIntent()). If it's not present, that means you do reload the activity's previous state. If it is, then you don't reload it.
Upvotes: 3