How can we understand the four Android startup mode? Few pictures on ok!

Foreword

CVTE the interview worst answer a topic. Ado, as long as the school should know that Android had four startup modes: standard, singleTop, singleTask, singleInstance.

mind Mapping

standard, singleTop, singleTask task stack for the corresponding app are current process, and singleInstance point to the entire system.

standard - Standard Mode

Activity of the default startup mode.

  • Features: Each time you start an Activity will create an instance.
  • Scenario: default.

singleTop - stack multiplexing

  • Features: If the top of the stack, not creating an instance. Otherwise created.
  • Scenario: The current page has to jump at the top of the stack, such as message notification Jump

singleTask - reuse within the stack

  • Features: If the stack memory, it will pop up after all instances of the stack .
  • Scenario: there is a dedicated app as the basis for the main page, so the app is now available in the market is also very common, like on a Activityembedded ViewPager+ BottomNavigationBarmade into a main page, as ViewPagerembedded in a lot of Fragmentthis time if it is standardor singleTopis form, it is easy for application Caton.

important point:

  • If another process opens the App Activity1, this time will create a new task stack

  • If you start in the startup mode Activity1 already active in a stack of background task, then after the start, the background to the foreground task will stack together.

singleInstance - globally unique

Different front three startup mode, he does not require the same instance of a task stack

  • Wherein: the system will be only one instance.
  • Scenario: application within the system, such as telephone, text messaging and other functions, by Intentthe time spread, fixed'll call these the system comes with the application, generally less use in their own applications.

At last

Now, a few pictures can easily understand! Easy to share, we can focus a point I like to support what!
There is more learning content has been uploaded to my GitHub, I attach a link: https://github.com/Meng997998/AndroidJX

Published 168 original articles · won praise 71 · views 20000 +

Guess you like

Origin blog.csdn.net/Aerfa789/article/details/104559415