鸿蒙开发之-UIAbility生命周期状态、生命周期方法和启动模式

UIAbility生命周期状态

  1. Create
  2. WindowStageCreate
  3. Foreground
  4. Background
  5. WindowStageWillDestroy
  6. WindowStageDestroy
  7. Destroy

UIAbility生命周期函数

  1. onCreate()
  2. onWindowStageCreate()
  3. onForeground()
  4. onBackground()
  5. onWindowStageDestroy()
  6. onDestroy()

页面及组件的生命周期

组件的生命周期钩子

  1. aboutToAppear()
  2. aboutToDisapper()

页面Page的生命周期钩子

  1. aboutToAppear()
  2. onPageShow()
  3. onBackPress()
  4. onPageHide()
  5. aboutToDisapper()

UIAbility启动模式

三种模式

  1. singleton 单实例模式(默认)
  2. multiton 多实例模式
  3. specified 指定实例模式

配置方式

module.json5配置文件中配置 launchType 字段

模式解释

  1. singleton:单实例模式,如果进程中已经有UIAbility实例存在,每次调用startAbility()时则复用系统中的实例,系统中只存在唯一的该UIAbility实例,最近任务列表中也只存在一个该类型的UIAbility实例;
  2. multiton:多实例模式,每次调用 startAbility() 方法时,都会在进程中创建该 UIAbility 实例,即在最近任务列表中可以看到有多少个该 UIAbility 实例;
  3. specified:指定实例模式,根据指定的key创建出多实例。
  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值