android - When do we need to override callback onConfigurationChanged()? -
if not want restart activity during config changes, can set flag android:configchanges
;
if need restart activity (i.e., update resources), should not set flag.
in situations, need set flag android:configchanges
while overriding callback onconfigurationchanged()
?
when set android:configchanges
in manifest, means telling system handle configuration change manually in activity
.
from doc of android:configchanges
:
lists configuration changes activity handle itself. when configuration change occurs @ runtime, activity shut down , restarted default, declaring configuration attribute prevent activity being restarted. instead, activity remains running , onconfigurationchanged() method called.
so if set configchanges
in manifest, have override onconfigurationchanged()
callback , handle change. otherwise system handle change automatically -- loading proper resource -- , don't have override onconfigurationchanged()
callback.
also doc:
using attribute should avoided , used last resort.
Comments
Post a Comment