Click the Android device back key, the home key, and how the rotation screen affects the activity's life cycle

Source: Internet
Author: User
  • Clicking the back key of the device is equivalent to notifying the Android system "I have finished using the activity and I don't need it now." "After receiving the instruction, the system immediately destroys the activity. That is, call OnPause ()->onstop ()->ondestroy ()
  • Click on the Home key, equivalent to notify Android "I'll take a look elsewhere and maybe come back later." "At this point, for a quick response to return to the app at any time, Android simply pauses the current activity without destroying it. Called OnPause ()->onstop (), but did not call OnDestroy ().

Note: There is no guarantee as to how long a stopped activity can be. If the system needs to reclaim memory, it will first destroy those stopped activity.

  • When the device rotates, the currently seen activity instance is destroyed by the system and a new activity instance is created. namely OnPause ()->onstop ()->ondestroy ()->oncreate ()->onstart ()->onresume (). Because rotating the device will change the device configuration. A device configuration is a series of features used to describe the current state of a device. These features include: orientation of the screen, screen density, screen size, keyboard type, docking mode, language, and so on.
  • Imagine a small pop-up window that partially obscures the current activity interface. When it appears, the masked activity is suspended by the system (OnPause ()) and the user cannot interact with it. When the small pop-up window is closed, the masked activity will start to run again.

Click the Android device back key, the home key, and how the rotation screen affects the activity's life cycle

Related Article

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.