赞
踩
本文介绍FA模型的三种应用组件如何绑定Stage模型的ServiceExtensionAbility组件。
PageAbility关联访问ServiceExtensionAbility和PageAbility关联访问ServiceAbility的方式完全相同。
import featureAbility from '@ohos.ability.featureAbility'; import common from '@ohos.app.ability.common'; import Want from '@ohos.app.ability.Want'; import Logger from '../../utils/Logger'; const TAG: string = 'PageInterflowFaAndStage'; let serviceWant: Want = { bundleName: 'com.samples.stagemodelabilityinteraction', abilityName: 'ServiceExtAbility' }; let faConnect: common.ConnectOptions = { onConnect: (elementName, proxy) => { Logger.info(TAG, "FaConnection onConnect called."); }, onDisconnect: (elementName) => { Logger.info(TAG, "FaConnection onDisconnect called."); }, onFailed: (code) => { Logger.info(TAG, "FaConnection onFailed code is: " + code); } }; let connectionId = featureAbility.connectAbility(serviceWant, faConnect);
ServiceAbility/DataAbility关联访问ServiceExtensionAbility和ServiceAbility/DataAbility关联访问ServiceAbility的方式完全相同。
import particleAbility from '@ohos.ability.particleAbility'; import common from '@ohos.app.ability.common'; import Want from '@ohos.app.ability.Want'; import hilog from '@ohos.hilog'; const TAG: string = '[Sample_FAModelAbilityDevelop]'; const domain: number = 0xFF00; let serviceWant: Want = { bundleName: 'com.samples.stagemodelabilityinteraction', abilityName: 'ServiceExtAbility' }; let faConnect: common.ConnectOptions = { onConnect: (elementName, proxy) => { hilog.info(domain, TAG, 'FaConnection onConnect called.'); }, onDisconnect: (elementName) => { hilog.info(domain, TAG, 'FaConnection onDisconnect called.'); }, onFailed: (code) => { hilog.info(domain, TAG, 'FaConnection onFailed code is: ' + code); } }; let connectionId = particleAbility.connectAbility(serviceWant, faConnect);
为了能让大家更好的学习鸿蒙(HarmonyOS NEXT)开发技术,这边特意整理了《鸿蒙开发学习手册》(共计890页),希望对大家有所帮助:https://qr21.cn/FV7h05
https://qr21.cn/FV7h05
https://qr21.cn/FV7h05
https://qr21.cn/FV7h05
https://qr18.cn/F781PH
https://qr18.cn/F781PH
1.项目开发必备面试题
2.性能优化方向
3.架构方向
4.鸿蒙开发系统底层方向
5.鸿蒙音视频开发方向
6.鸿蒙车载开发方向
7.鸿蒙南向开发方向
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。