#鸿蒙通关秘籍#进程模型中,UIAbility和ServiceExtensionAbility运行在哪个进程中?

HarmonyOS
2024-12-02 11:13:54
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
SSD孤星泪

UIAbility和ServiceExtensionAbility运行在同一个独立进程中。

import { UIExtensionAbility, Want, common } from '@kit.AbilityKit';
import { rpc } from '@kit.IPCKit';
import { BusinessError } from '@kit.BasicServicesKit';

export default class EntryAbility extends UIExtensionAbility {
onForeground() {
let want: Want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let commRemote: rpc.IRemoteObject;
let options: common.ConnectOptions = {
onConnect(elementName, remote) {
commRemote = remote;
console.info('onConnect...')
},
onDisconnect(elementName) {
console.info('onDisconnect...')
},
onFailed(code) {
console.info('onFailed...')
}
};
let connection: number;
try {
connection = this.context.connectServiceExtensionAbility(want, options);
} catch (err) {
// 处理入参错误异常
let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.error(`connectServiceExtensionAbility failed, code is ${code}, message is ${message}`);
}
}
}
已于2024-12-19 18:39:26修改
分享
微博
QQ
微信
回复
2024-12-02 11:37:10
相关问题
HarmonyOS 在应用增加子进程UIAbility
198浏览 • 1回复 待解决
WebView进程模型渲染机制是什么
2266浏览 • 1回复 待解决
多个UIAbility是多个进程吗?
2213浏览 • 1回复 待解决
多个UIAbility是多个进程
2438浏览 • 1回复 待解决