I have Android application and own Application derived class holding some internal data.
Among other there are some string fields. The problem is that if I put the application in foreground, work on other application, switch back to my app again, the app may be restarted because it got killed by system. Unfortunatelly the Application object seems not to be created again because the onCreate method of application object doesn’t get called and all fields are set to null. My Activity gets recreated but all Application’s object fields are null. When is the Application.onCreate method called? How to handle it?
I have Android application and own Application derived class holding some internal data. Among
Share
there is no onCreate that you can register to.
in later API’s there’s a way to register to the Activity lifecycle functions. and then you can do what ever you want.
basically, what you should do is use
SharedPrefrencesfor storing information.what I would do is: