Life cycle of Android screen switching

Source: Internet
Author: User

Now the phone by default, you can switch between the screen, but the life cycle of the screen switching is how, today to explain, in case you develop the app screen when the game over

1. Load an activity's print log without making any configuration:


Print log for direction when switching screen:

PS: I don't see anything here. Horizontal screen Switch vertical screen when performing two times OnCreate, personally feel wrong

2. When the android:configchanges= "Keyboardhidden|orientation|screensize" is configured, the restart activity does not occur when the screen switches

3. When configuring Android:configchanges= "Keyboardhidden|orientation", the

(1) android:targetsdkversion>12, the screen switch or restart activity will occur.

(2) android:targetsdkversion<=12 , when the screen is switched, the activity is not restarted and only calls Onconfigurationchanged

4. When configuring android:configchanges= "orientation", restart the activity when the screen switches


Summarize:

1. When the android:configchanges= "orientation" is not configured and configured, the activity needs to be restarted when the screen switches

2. When configuring Android:configchanges= "Keyboardhidden|orientation|screensize", when the screen switches, do not restart activity, execute onconfigurationchanged

3. Configure android:configchanges= "Keyboardhidden|orientation"

(1) android:targetsdkversion>12, the screen switch or restart activity will occur.

(2) android:targetsdkversion<=12 , when the screen is switched, the activity is not restarted and only calls Onconfigurationchanged


Life cycle of Android screen switching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.