1 Star 0 Fork 5.4K

ohos / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
js-apis-inner-application-missionCallbacks.md 1.87 KB
一键复制 编辑 原始数据 按行查看 历史

MissionCallback

作为可以registerMissionListener的入参,表示开始同步后,建立的回调函数。

说明:

本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

系统能力:SystemCapability.Ability.AbilityRuntime.Mission

名称 类型 可读 可写 说明
notifyMissionsChanged(deviceId: string) function 通知任务变化,返回设备ID。
notifySnapshot(deviceId: string, mission: number) function 通知快照变化,返回设备ID,任务ID
notifyNetDisconnect(deviceId: string, state: number) function 通知断开连接,返回设备ID,网络状态

示例:

import distributedMissionManager from '@ohos.distributedMissionManager';

let missionDeviceInfo = {
    deviceId: '123456'
};
let missionCallback = {
    notifyMissionsChanged: function (deviceId) {
        console.log('notifyMissionsChanged deviceId: ${JSON.stringify(deviceId)}');
    },
    notifySnapshot: function (deviceId, mission) {
        console.log('notifySnapshot deviceId: ${JSON.stringify(deviceId)}');
        console.log('notifySnapshot mission: ${JSON.stringify(mission)}');
    },
    notifyNetDisconnect: function (deviceId, state) {
        console.log('notifyNetDisconnect deviceId: ${JSON.stringify(deviceId)}');
        console.log('notifyNetDisconnect state: ${JSON.stringify(state)}');
    }
};
distributedMissionManager.registerMissionListener(missionDeviceInfo, missionCallback);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yeyinglong/docs.git
git@gitee.com:yeyinglong/docs.git
yeyinglong
docs
docs
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891