Android:configchanges= "Keyboardhidden|orientation" is configured when you turn the screen
The oncreate will still be called because the screensize property is not configured to cause it.
Reference: http://blog.csdn.net/huiguixian/article/details/8071821
In previous versions, as long as the activity was specified android:configchanges= "keyboardhidden|orientation" property in the Androidmanifest.xml file, The OnCreate () function is not called again when the screen is turned, but instead calls Onconfigurationchanged ().
However, since android3.2, if you set this up again, you will notice that OnCreate () is still called after the screen is turned, not onconfigurationchanged (); Trace the framework layer code, you will find the problem, is because Google in android3.2 added screensize change Notice, in the Turn screen, not only orientation changed, screensize also changed, but in the judgment is to call onconfigurationchanged or ONCR When Eate, the following judgment is used:
int diff = activity.mCurrentConfig.diff (config);
if (diff! = 0) {
If This activity doesn ' t handle any of the config changes and then don ' t bother calling onconfigurationchanged as we ' regoin G to destroy it.
if ((~activity.mactivityinfo.getrealconfigchanged () & diff) = = 0) {
Shouldchangeconfig = true;
}
}
public int getrealconfigchanged () {
Return Applicationinfo.targetsdkversion < Android.os.Build.VERSION_CODES. HONEYCOMB_MR2? (Configchanges | Activityinfo.config_screen_size
| activityinfo.config_smallest_screen_size): configchanges;
}
With the above analysis, there are two ways to solve the problem: (only modify Androidmanifest.xml)
1. Specify android:configchanges= "Keyboardhidden|orientation|screensize", and the other code is treated like the previous code;
2. In Androidmanifest.xml, specifying Targetsdkversion as the previous version of 3.2 (version number 13 for 3.2), the system automatically adds ScreenSize property values.
For example: <uses-sdk android:minsdkversion= "3" android:targetsdkversion= "/>"
The first method is recommended.
Android:configchanges Attribute Considerations