Simple question: can you be sure that finish() will call onDestroy()?
First, this answer assumes that you are referring to Android's Activity
class and its finish()
method and onDestroy()
lifecycle method.
Second, it depends upon your definition of "sure":
Your process could be terminated in between
finish()
andonDestroy()
, for reasons independent of whatever is triggering the call tofinish()
A device manufacturer or ROM modder could introduce some screwy change that would break the connection between
finish()
andonDestroy()
The battery could go dead in between
finish()
andonDestroy()
Etc.
Third, finish()
does not call onDestroy()
. You can tell that by reading the source code. finish()
usually triggers a call to onDestroy()
.
Generally speaking, finish()
will eventually result in onDestroy()
being called.