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