建议参考官网样例使用,报错17700024是因为没有传入对应的resource;getProfileByAbility接口获取的是模块下的module.json5配置项中,abilities内的metadata resource内容,当不传metadataName时,获取的是对应abilityName下的所有metadata配置的resource内容;metadata参考配置:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/module-configuration-file-V5try { bundleManager.getProfileByAbility('entry','EntryAbility','string').then((data) => { hilog.info(0x0000, 'testTag', 'getProfileByAbility successfully. Data: %{public}s', JSON.stringify(data)); }).catch((err: BusinessError) => { hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', err.message); }); } catch (err) { let message = (err as BusinessError).message; hilog.error(0x0000, 'testTag', 'getProfileByAbility failed. Cause: %{public}s', message); }配置:"metadata": [{ "name": "string", "value": "string", "resource": "$profile:metadata_con" }],
建议参考官网样例使用,报错17700024是因为没有传入对应的resource;getProfileByAbility接口获取的是模块下的module.json5配置项中,abilities内的metadata resource内容,当不传metadataName时,获取的是对应abilityName下的所有metadata配置的resource内容;
metadata参考配置:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/module-configuration-file-V5
配置: