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

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -