一個項目包含entry+n個module鉴腻,無法從entry跳轉(zhuǎn)到module中的ability。理論上應(yīng)該可以正常執(zhí)行飒箭,不知是否是官方bug姚糊?目前可以在entry中跳轉(zhuǎn)library的ability。
操作前提:
1浪默、新建module選擇 xxxx ability牡直,完成創(chuàng)建;
2纳决、entry中添加gradle依賴:implementation project(" : xxxx")碰逸;
3、事件觸發(fā)阔加,執(zhí)行intent (跳轉(zhuǎn)失敹贰);
Intent in = new Intent();
Operation operation = new Intent.OperationBuilder()
.withBundleName(getBundleName())
// .withBundleName("com.harmony.myhmdemo")
// .withAbilityName("com.harmony.settingmodule.SettingAbility")
.withAbilityName(SettingAbility.class.getName())
.withDeviceId("")
.build();
in.setOperation(operation);
startAbility(in);
4胜榔、設(shè)置跳轉(zhuǎn)intent時注意點:
---bundleName為entry--config.json中的bundleName胳喷,非package;
---abilityName為module中對應(yīng)ability路徑夭织;
解決步驟:
1吭露、在module的gradle中設(shè)置plugin為library,
'com.huawei.ohos.hap' ===> ''com.huawei.ohos.library"
去掉:entryModules : "entry"
2尊惰、修改module的config.json
"distro": {
"deliveryWithInstall": true,
"moduleName": "settingmodule",
"moduleType": "har" # 創(chuàng)建module時默認(rèn)為feature
}