应用如何通过隐式want拉起自己的ability?

应用如何通过隐式want拉起自己的ability?

HarmonyOS
2024-09-19 11:05:58
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
FengTianYa

如果module.json5中的AbilityA的skills中仅配置了actions,则可以直接通过want-action做条件进行拉起,在模块module中配置。

{ 
  "name": "OtherAbility", 
  "srcEntry": "./ets/otherability/OtherAbility.ets", 
  "description": "$string:OtherAbility_desc", 
  "icon": "$media:layered_image", 
  "label": "$string:OtherAbility_label", 
  "startWindowIcon": "$media:startIcon", 
  "startWindowBackground": "$color:start_window_background", 
  "launchType": "specified", 
  "skills": [ 
    { 
      "actions": [ 
        "actions.tpns.push" 
      ] 
    } 
  ] 
}

在任意点击事件中添加。

let wantInfo: Want = { 
  bundleName: "com.example.mybundleName",//需要指定bundleName 
  action: 'actions.tpns.push', 
} 
let context = getContext() as common.UIAbilityContext 
context.startAbility(wantInfo)
分享
微博
QQ
微信
回复
2024-09-19 16:14:54
相关问题
#鸿蒙学习大百科#什么是Want
316浏览 • 1回复 待解决
如何测试自己开发应用
2397浏览 • 1回复 待解决