DevEco Studio默认工程未包含AbilityStage。若需使用AbilityStage功能,可手动创建AbilityStage文件。具体步骤如下:
import { AbilityStage, Want } from '@kit.AbilityKit';
export default class MyAbilityStage extends AbilityStage {
onCreate(): void {
// When the HAP of the application is first loaded, initialize the operation for the module
}
onAcceptWant(want: Want): string {
// Triggered only when UIAbility is configured in specified startup mode
return 'MyAbilityStage';
}
} {
"module": {
"name": "entry",
"type": "entry",
"srcEntry": "./ets/myabilitystage/MyAbilityStage.ets",
// ...
}
} AbilityStage拥有onCreate()、onDestroy()生命周期回调和onAcceptWant()、onConfigurationUpdate()、onMemoryLevel()事件回调等。