Reputation: 589
My code destroy my current activity and start a new activity, like below:
Intent intent = myActivity.getIntent();
myActivity.finish(); //Destroy my activity
myActivity.startActivity(intent); //Start my new activity
It works, the previous activity is destroyed and new activity starts, but AFTER start the new activity, the activity's onDestroy()
method is called, why?
Upvotes: 0
Views: 1411
Reputation: 45070
From the android docs:-
protected void onDestroy ()
Perform any final cleanup before an activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method.
Upvotes: 0