I appear to have the opposite issue to every other post on the topic I have come across. Others find that onDestroy() is not always called but I find it always and immediately is.
I am checking whether it is called with the following:
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy");
}
This log code is triggered immediately after either clicking back or using my actionbar button which just calls the home activity as an intent.
I have looked around but everyone says the lifecycle should look like this: http://developer.android.com/images/activity_lifecycle.png
This behaviour is not limited to a single app; I have tried downloading some example code and adding in the above debugging code only to find the same behaviour. It is also not limited to a single android version; I have tried 2.1 and 2.3 in the emulator and also 4.0.2 on a physical device.
Any ideas of what I might be doing wrong?
pressing back key actually provokes finish()
method on your activity, and it causes your activity to be paused->stopped->destroyed
so technically this behavior is functional as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With