Does onRetainNonConfigurationInstance() calls each time on configuration change?
Does onRetainNonConfigurationInstance() calls each time on configuration change, i.e. when I change orientation of my device? I override it and checked it does, but what confuses me is that this note in the documentation.
This function is called purely as an optimization, and you must not rely on it being开发者_如何转开发 called.
Does it guaranteed this method is called on orientation change?
This note means that your app's functionality should not depend on onRetainNonConfigurationInstance
being called for proper function. That is, your program should not crash or behave erratically if a device is rotated, but onRetainNonConfigurationInstance
is not called.
If it does get called, then you can use it to speed up the re-creation of your Activity.
精彩评论