Android activity-coordinates Activity

Source: Internet
Author: User

When one activity starts another activity, they all undergo a life cycle conversion. When the first activity is paused and terminated (even if it is still visible and does not want to be terminated), the other activity will be created. In this case, the data shared by the activity should be stored on a CD or elsewhere. It is essential to understand that the first activity cannot be completely terminated before the second activity is created. Otherwise, the process of the second activity being started will overwrite the process of the first activity being terminated.

 

Especially when switching between two activities in the same process, the lifecycle callback sequence is well defined. The following operations occur when activity a starts Activity B.

1. The onpause () method of Activity A is executed;

2. oncreate (), onstart (), and onresume () of Activity B are executed sequentially (currently Activity B has the user focus );

3. Then, if activity A is no longer displayed on the screen, its onstop () method will be executed.

The foreseeable order of lifecycle callback allows you to manage switching information between two activities. For example, when the first activity ends, you must write the data to the database so that the next activity can read it. Then, you should write the data to the database during the onpause () method execution, instead of during the onstop () method execution.

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.