Issue
I am still not clear about this point and I did not find really clear explanations: what are the objects/components that should be closed/deleted on the onDestroy
callbacks?
From what I read, there would be at least:
- listeners to remove
- database handler to close
But are there other things to handle?
Thanks!
Solution
There is no reason to explicitly close something only because it's a database handler or a listener. .
You would want to kill the things that you do not need anymore but that can be mistakenly called after onDelete (or onStop) occured.
Those can be: services because thay are likely not to be killed by OS and thus run while no one needs them. Broadcast receivers because they can get a message from the system and try to process it while your activity is already invalid. Handlers because they can receive messages from other part of your app. Listeners and databases connections because other parts of your app can inadvertently use them while the activity that provides them is already in invalid state. So, it's a matter of logic what to close in onStop / onDestroy and not a matter of classification.
Answered By - Alexander
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.