HarmonyOS 鸿蒙Next:module_entry_entry.cj和ability_mainability_entry.cj什么时候调用?被谁调用?
HarmonyOS 鸿蒙Next:module_entry_entry.cj和ability_mainability_entry.cj什么时候调用?被谁调用?
在helloCanjie例程中
module_entry_entry.cj代码:
package ohos_app_cangjie_entry
import ohos.ability.AbilityStage
let ENTRY_STAGE_REGISTER_RESULT = AbilityStage.registerCreator(“entry”, {=> MyAbilityStage()})
==========================================================================
ability_mainability_entry.cj代码:
package ohos_app_cangjie_entry
import ohos.ability.Ability
let ENTRYABILITY_REGISTER_RESULT = Ability.registerCreator(“EntryAbility”, {=> MainAbility()})
这两个文件,什么时候被调用?被哪个文件或代码调用?
从module.json5中:
{
“module”: {
“name”: “entry”,
“type”: “entry”,
“description”: “$string:module_desc”,
“mainElement”: “EntryAbility”,
“deviceTypes”: [
“phone”
],
“deliveryWithInstall”: true,
“installationFree”: false,
“srcEntry”: “ohos_app_cangjie_entry.MyAbilityStage”,
“abilities”: [
{
“name”: “EntryAbility”,
“srcEntry”: “ohos_app_cangjie_entry.MainAbility”,
可以看到,在HAP加载后,要创建一个abilityStage,这里的abilityState名称应该是entry,代码是MyAbilityStage,而MyAbilityStage继承自AbilityState,从文件 ability_stage.cj可以看出:
class MyAbilityStage <: AbilityStage {
public override func onCreate(): Unit {
AppLog.info(“MyAbilityStage onCreated.”)
}
}
但是怎么调用文件 module.entry.entry.cj的,不明白:
let ENTRY_STAGE_REGISTER_RESULT = AbilityStage.registerCreator(“entry”, {=> MyAbilityStage()})
这是在什么配置文件中配置好的吗?
更多关于HarmonyOS 鸿蒙Next:module_entry_entry.cj和ability_mainability_entry.cj什么时候调用?被谁调用?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于HarmonyOS 鸿蒙Next:module_entry_entry.cj和ability_mainability_entry.cj什么时候调用?被谁调用?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html