onDestroy does not mean that the activity object has been deleted, it just means that the activity itself (as the concept of Android) was destroyed. This has nothing to do with the actual Activity object. Internally, the OS may decide to recycle it, especially when it is immediately recreated due to a configuration change (for example, the orientation changes from portrait to landscape).
Even if it were garbage collection (which could have happened much later after onDestroy, at a point on the road when the system really needed to do garbage collection because it needed memory), there is no guarantee finalize . This is even in the documentation:
"Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called.".
Generally, you should never use finalize unless you really need to. This is not as predictable as a destructor in C ++. If you need to perform a cleanup in your activity, do it in onPause or onDestroy or any other hook.
source share