Should all activities be modeled as fragments?
A frequently asked question is "how do you maintain your activity's state
between configuration changes?".
Answers to this question seem largely dependent upon the developer's
preference. However, one thing does appear certain - refrain from using
android:configChanges="orientation|screenSize" in the Manifest file (see
LINK).
Therefore, to ensure stability we ought to retain an object during
configuration change as suggested by android (see LINK). However, this
requires the use of onRetainNonConfigurationInstance that has been
deprecated in API 13; instead it suggests that we use setRetainInstance of
the Fragment class.
Given this preference by Android for fragments, should we now be designing
our activities where the main UI is itself a fragment, and the activity
just serves as a 'driver' or 'fragment manager' for the 'main fragment'
and any possible 'fragment children' it may have?
In addition, am I right in thinking that setting
android:configChanges="orientation|screenSize" in the manifest file is
actually okay providing you're using the same resources for both landscape
and portrait views?
No comments:
Post a Comment