I have a singleton in an activity. When I end my application (like pressing back button), and start it again after some time, the singleton is not recreated, but is holding previous state. Singleton is not destroyed if the application is destroyed? Do I have to null its static members in onDestroy() to avoid memory leak?
Thanks.
I have a singleton in an activity. When I end my application (like pressing
Share
When you are ‘ending’ your activity it is just going in background. So state will be maintained. If you want to do something when the activity is not ‘visible’ you have to implement the
onStop()method and notonDestroy().Please refer how android manages stack of Tasks and activities. Also refer Activity Lifecycle.