Hi Mark,
On Jun 4, 5:57 pm, "Mark Murphy" <[email protected]> wrote:
> onSaveInstanceState() is called in cases other than screen rotations
> (e.g., activity is being closed up due to low memory), and in those other
> cases, onRetainNonConfigurationInstance() is not used at all.
yes, but wouldn't it be more clever to have
onRetainLastNonConfigurationInstance() be called *before*
onSaveInstanceState(), because then one could determine whether it's
necessary to have the latter actually do something. For those cases I
mentioned (which I suppose are the more typical use cases), this would
be very helpful, because you could do something like this:
protected Object onRetainLastNonConfigurationInstance() {
return expensiveObject;
}
protected void onSaveInstanceState(Bundle out) {
if (getLastNonConfigurationInstance() == null) {
// serialize expensiveObject to bundle
}
}
protected void onCreate(Bundle in) {
Object expensiveObject = getLastNonConfigurationInstance();
if (expensiveObject == null) {
// deserialize expensiveObject
}
}
using that approach, one could benefit from that method in, what,
99.9% of all situations in which onSaveInstanceState() is called? (by
which I mean orientation changes, not low memory scenarios).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---