启动模式种类

分四种:standard,singleTop、singleTask、singleInstance。

可以在AndroidManifest.xml中通过给<activity>标签指定android:launchMode属性来选择启动模式


standard

standard是活动默认的启动模式,在不进行显式指定的情况下,所有活动都会自动使用这种启动模式。原理图如下:

android 活动的启动模式

singleTop

当活动的启动模式指定为singleTop,在启动活动时如果发现返回栈的栈顶已经是该活动,则认为可以直接使用它,不会再创建新的活动实例(非栈顶则会创建)。

singleTask


singleInstance

相关文章:

  • 2021-11-19
  • 2021-05-03
  • 2021-04-30
  • 2021-07-29
  • 2022-12-23
  • 2021-11-18
  • 2021-11-19
  • 2021-11-19
猜你喜欢
  • 2021-11-19
  • 2021-06-07
  • 2021-10-19
  • 2021-10-01
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案