Can't retrieve sharedPreference when activity is resumed from history on Samsung Galaxy S 2.2.1
Have a user who just updated to 2.2.1 on his Galaxy S. Now, when he hi开发者_运维技巧ts HOME and then relaunches the app, I can see in the logs that the application context is re-initialized and a new process ID is created (verified via log messages in onCreate() in my application instance.)
The odd thing is that when it is relaunched from history, my shared preferences where I store important state are no longer available and all requests to context.getSharedPreferences(PREFS_FILE, Mode.WORLD_PRIVATE).getString() return NULL which ultimately leads to a force-close.
After re-launching the app again, everything works as expected and the sharedPreferences are again available.
I've only noticed this on the Samsung Galaxy S after he upgraded to 2.2.1.
The odd thing I'm curious about is the fact that it appears a new process is launched when returning to the app.
Has anyone else seen this behavior? Perhaps I'm doing something wrong?
I've read a little about task re-parenting, etc, from http://developer.android.com/guide/topics/manifest/activity-element.html#proc, but not sure any options would really help here?
I ended up modifying my PreferenceActivity subclass to initialize the shared prefs from a database table when the activity starts and to write to the database when a value has changed. PITA, but all Samsung S issues are now gone.
It seems to be samsung issue - I've noticed very similar issue with 2.2.1 ROM on Galaxy S
精彩评论