HarmonyOS 鸿蒙Next中应用之间如何跳转

HarmonyOS 鸿蒙Next中应用之间如何跳转 应用之间如何跳转,类似实现安卓上从一个应用打开另外一个应用

2 回复

用want,写上对面应用的包名和ability,比如

let want: Want = {
  bundleName: 'com.amap.hmapp', //高德地图
  abilityName: 'EntryAbility' //新建项目默认就是这个ability,如果对方修改了,但你又不知道,那就会跳转失败,提示Failed to startAbility. Code: 16000001, message: The specified ability does not exist.
};

参考:https://developer.huawei.com/consumer/cn/forum/topic/0203149681815248158?fid=0109140870620153026

更多关于HarmonyOS 鸿蒙Next中应用之间如何跳转的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS(鸿蒙Next)中,应用之间的跳转主要通过IntentAbility机制实现。开发者可以使用Intent对象指定目标应用的Ability,并通过startAbility方法启动目标应用。例如:

Intent intent = new Intent();
Operation operation = new Intent.OperationBuilder()
    .withDeviceId("")
    .withBundleName("com.example.targetapp")
    .withAbilityName("com.example.targetapp.MainAbility")
    .build();
intent.setOperation(operation);
startAbility(intent);

这种方式适用于应用间的显式跳转,确保目标应用和Ability的准确启动。

回到顶部