I am new to Android development. We are currently trying to port our existing framework on to Android. We have a core library (existing one) which exposes a singleton instance which provides us a set of flags based on which certain operations are performed. Now when i perform certain operations and flags of the single instance are modified. When i exit the application and restart it, my expectation was that these flags should have been reset to the default values, but it fails.. :-(. Ive read in several posts that the reference would still be active until the application is killed by the OS. Can someone suggest me how to overcome this issue.开发者_如何学JAVA Any work around?
I suspect you aren't actually exiting the application. In Android, simply navigating away from the Activity doesn't close an application. In fact, you shouldn't really close applications in Android, as the VM manages that task rather efficiently. If you need to reset a default set of parameters for an application, you could do so in the Activity's onResume() method.
A quick workaround is to call System.exit(1) in onDestroy which kills the whole application. But its not a good practice.
精彩评论