ConfigurationChange
Handling the Configuration Change Yourself
public final class
Configuration
onConfigurationChanged(Configuration newConfig)
フラグメントは、mFragments.dispatchConfigurationChanged(newConfig);の方かな?
https://github.com/android/platform_frameworks_base/blame/master/core/java/android/app/Activity.java
GitHubの一部分だけコードを貼るやり方がわかるといいな。
1399 /** 1400 * Called by the system when the device configuration changes while your 1401 * activity is running. Note that this will <em>only</em> be called if 1402 * you have selected configurations you would like to handle with the 1403 * {@link android.R.attr#configChanges} attribute in your manifest. If 1404 * any configuration change occurs that is not selected to be reported 1405 * by that attribute, then instead of reporting it the system will stop 1406 * and restart the activity (to have it launched with the new 1407 * configuration). 1408 * 1409 * <p>At the time that this function has been called, your Resources 1410 * object will have been updated to return resource values matching the 1411 * new configuration. 1412 * 1413 * @param newConfig The new device configuration. 1414 */ 1415 public void onConfigurationChanged(Configuration newConfig) { 1416 mCalled = true; 1417 1418 mFragments.dispatchConfigurationChanged(newConfig); 1419 1420 if (mWindow != null) { 1421 // Pass the configuration changed event to the window 1422 mWindow.onConfigurationChanged(newConfig); 1423 } 1424 1425 if (mActionBar != null) { 1426 // Do this last; the action bar will need to access 1427 // view changes from above. 1428 mActionBar.onConfigurationChanged(newConfig); 1429 } 1430 } http://tools.oesf.biz/android-4.0.3_r1.0/xref/frameworks/base/core/java/android/app/Activity.java
/frameworks/base/core/java/android/view/Window.java 994 /** 995 * Should be called when the configuration is changed. 996 * 997 * @param newConfig The new configuration. 998 */ 999 public abstract void onConfigurationChanged(Configuration newConfig); http://tools.oesf.biz/android-4.0.3_r1.0/xref/frameworks/base/core/java/android/view/Window.java
/frameworks/base/core/java/android/view/View.java 5918 /** 5919 * Called when the current configuration of the resources being used 5920 * by the application have changed. You can use this to decide when 5921 * to reload resources that can changed based on orientation and other 5922 * configuration characterstics. You only need to use this if you are 5923 * not relying on the normal {@link android.app.Activity} mechanism of 5924 * recreating the activity instance upon a configuration change. 5925 * 5926 * @param newConfig The new resource configuration. 5927 */ 5928 protected void onConfigurationChanged(Configuration newConfig) { 5929 } http://tools.oesf.biz/android-4.0.3_r1.0/xref/frameworks/base/core/java/android/view/View.java