android saveinstance saving vector datatypes
I am making an application which is currently working perfectly but with only 1 problem... As we all kno开发者_Python百科w that the activity is destroyed and recreated when user changes the orientation of the phone... my activity needs to save a vector full of objects wen the activity is recreated... i checked the OnSaveInstance() method and found that there is no way a vector can be stored... Does any1 have a suggestion for storing vector so that i can retrieve it on recreation of Activity???
Any help will be appreciated...
Thanx...
Yep, there's a mechanism in place for this purpose.
- Implement/override
onRetainNonConfigurationInstance
in yourActivity
class, returning the state object you want to persist across orientation changes (in this case, a vector or what not) - In your
onCreate
oronStart
or what not, access the stored object by callinggetLastNonConfigurationInstance
. If it's null, recreate the object.
精彩评论