Activity Startup Mode record

Source: Internet
Author: User

Android: launchmode = "standard": In this startup mode, every startactivity () is used to create a new instance in the memory.

Android: launchmode = "singletop": if a reference to this activity exists at the top of the stack, startactivity () will not create a new oncreate, but reuse existing instances, call the onnewintent () method.

Android: launchmode = "singletask": as long as there is a reference to this activity in the entire stack, startactivity () will not create a new oncreate, but reuse the existing instance and call onnewintent () method.

Android: launchmode = "singleinstance": After being created for the first time, another task stack is enabled, and only one reference of the new stack can exist. startactivity () instead of creating a new instance in oncreate, the existing instance is reused and the onnewintent () method is called.

Let's take a look at the startactivityforresult () method: (test)

Now we can demonstrate that a startactivityforresult () enables B and B returns data;

If a is standardb with singletask and singleinstance, an error is returned. A calls startactivityforresult () to enable B, and CALLS onactivityresult () of a immediately (); in this case, no data is returned for Operation B (not obtained yet). If operation B is singletop and standard, data is returned normally. If a is singletop, same as above. If a is singletask, same as above. If a is singleinstance, all data is returned.

To sum up, if you need to enable the System camera in your activity and then return data, please do not set your activity to singleinstance; if it is not a singleinstance, therefore, the onactivityresult method cannot be used to obtain the returned data. You can obtain the image from the SD card after saving the photo.

The setresult () method is invalid in onpause and ondestory. Other lifecycle methods are valid.

Ondestory () is called every time you press the back key ();

Calling this. Finish () will automatically call ondestory ();

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.