subscribeInfo.setDeviceId()没有效果

subscribeInfo.setDeviceId()没有效果-开源基础软件社区

设备B设置subscribeInfo.setDeviceId(DeviceIdA);指定订阅了设备A的公共事件,但是设备A发布公共事件的时候设备B没有响应

    //①订阅远程事件
    public void subscribeEvent(String DeviceIdA) {
        MatchingSkills matchingSkills = new MatchingSkills();
        matchingSkills.addEvent("REMOTE_ACTION");
        CommonEventSubscribeInfo subscribeInfo = new CommonEventSubscribeInfo(matchingSkills);
        //指定订阅哪台设备的公共事件
        subscribeInfo.setDeviceId(DeviceIdA);
        subscriber = new MyCommonEventSubscriber(subscribeInfo);
        try {
            CommonEventManager.subscribeCommonEvent(subscriber);
            HiLog.info(HI_LOG_LABEL, "订阅远程公共事件成功√。");
        } catch (RemoteException e) {
            HiLog.error(HI_LOG_LABEL, "订阅远程公共事件失败。");
        }
    }
    //②发布远程事件
    public void publishRemoteEvent() {
        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                .withAction("REMOTE_ACTION")
                .build();
        intent.setOperation(operation);
        CommonEventData eventData = new CommonEventData(intent);
        try {
            CommonEventManager.publishCommonEvent(eventData);
            HiLog.info(HI_LOG_LABEL, "发布远程公共事件成功√。");
        } catch (RemoteException e) {
            HiLog.error(HI_LOG_LABEL, "发布远程公共事件失败。");
        }
    }
HarmonyOS
2022-04-15 21:46:30
浏览
已于2022-4-15 21:47:55修改
收藏 0
回答 1
已解决
回答 1
按赞同
/
按时间
Claphame
2

目前不支持跨设备订阅公共事件。

分享
微博
QQ
微信
回复
2022-04-20 14:21:56
相关问题
如何去掉div长按的灰色效果
562浏览 • 1回复 待解决
Text实现scroll效果怎么弄?
2723浏览 • 1回复 待解决
鸿蒙中怎么实现动画翻转效果
7907浏览 • 2回复 待解决
arkts 什么时候可以实现模糊效果
633浏览 • 1回复 待解决
求助动画效果问题有懂的吗?
2264浏览 • 1回复 待解决
HarmonyOS没有IntentFilter
3986浏览 • 1回复 待解决
HDF驱动没有生成节点,也没有Log
5073浏览 • 1回复 待解决