The difference between Android Singletask and SingleInstance

Source: Internet
Author: User

In Wednesday went to NetEase interview was asked this question, then did not answer right, came back specially wrote a program to study.

About Android activity start mode A total of four standard singletop singletask singleinstance these four kinds

Standard and Singletop are better understood, here is the main study of Singletask singleinstance difference

The first is: Singletask

Assuming that two activity is a and b respectively, activity A's startup mode is standard activity B's startup mode is Singletask, a can start B, and B can also start a

Through a start B, you can find that a B's taskid is the same, stating that A and B run in the same stack, and then through B start A is also in this stack, now this stack from the bottom of the stack to the top of the order is a-b-a, And then start B again with a B at this time the Lanchmode is working. Through the test found that the stack does not produce a new instance of B, the previous time always thought the stack is such a a-a-b (PS: At the time of the interview I answered this) the actual operation result is a B in the middle of a directly destroyed.

Followed by: SingleInstance

Assuming that two activity is a and b respectively, activity A's startup mode is standard activity B's startup mode is SingleInstance, a can start B, and B can also start a

Through a start B, you can find that a B's taskid is not the same, stating that a start B when a new stack, b run in a new stack, the time through B again to start a now two stacks inside the case is this, the original stack: a-a new stack: B

Then through a again start B can be found in the new stack does not produce a new instance of B the new stack is still: B is only B is displayed to the front;

Summary: The difference between Singletask and singleinstance is that Singletask will not generate a new stack, singleinstance the first call will generate a new stack, Singletask mode If an instance of activity is already present in the original stack, all activity in the middle will be destroyed the next time the call is made.

The difference between Android Singletask and SingleInstance

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.