I'm starting the activity "B" from the activity "A". When I'm closing the activity B using the back button or method finish(), the activity A is recreating. How can i deny activity to be destroyed?
Asked
Active
Viewed 62 times
-5
-
what you want to do?? – Sagar Maiyad Apr 22 '14 at 09:43
-
Yes, that is expected behaviour. See http://developer.android.com/training/basics/activity-lifecycle/index.html – Graham Borland Apr 22 '14 at 09:45
-
1You can't. You have to write your app to cope with it. – Graham Borland Apr 22 '14 at 09:45
-
I know this lifecycle. But I heard it is possible to break the cycle. – Ingvar Apr 22 '14 at 09:47
-
@Ingvar it's possible to manipulate the activity stack not activity lifecycle, see my asnwer – Ahmad Dwaik 'Warlock' Apr 22 '14 at 13:24
1 Answers
0
Activities in android are stored in a Stack called activity-stack, when you go to next Activity it's added to the stack, when you go back you pop last element from stack and nothing points at it any more, so not destroying is just waste of space!
Even if you override the back button to launch previous activity with noHistory
or clearTop
flag, current activity would be destroyed.
I suggest that you read more on activity lifecycle

Ahmad Dwaik 'Warlock'
- 5,953
- 5
- 34
- 56