Skip to content Skip to sidebar Skip to footer

Instance Variable Getting Set To Null If Activity Is Recreated By Os

I have been struggling with this problem for quite some time now. Instance variables of my main activity are getting set to null if I start app after a day. So, for my users every

Solution 1:

Android will kill or release memory of background applications as needed. So, you need to maintain state of your application when it goes into the background.

Try overriding both onSaveInstanceState and onRestoreInstanceState to save and restore the values of these instance variables.

Post a Comment for "Instance Variable Getting Set To Null If Activity Is Recreated By Os"