harmony 鸿蒙MissionListener

2022-12-22 浏览 (651)

MissionListener

The MissionListener module defines the listeners used to observe the mission status. The listeners can be registered by using on.

NOTE

The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import missionManager from '@ohos.app.ability.missionManager';

Attributes

System capability: SystemCapability.Ability.AbilityRuntime.Mission

System API: This is a system API and cannot be called by third-party applications.

NameTypeMandatoryDescription
onMissionCreatedfunctionNoCalled when the system creates a mission.
onMissionDestroyedfunctionNoCalled when the system destroys the mission.
onMissionSnapshotChangedfunctionNoCalled when the system updates the mission snapshot.
onMissionMovedToFrontfunctionNoCalled when the system moves the mission to the foreground.
onMissionLabelUpdated9+functionNoCalled when the system updates the mission label.
onMissionIconUpdated9+functionNoCalled when the system updates the mission icon.
onMissionClosed9+functionNoCalled when the system closes the mission.

Example

import missionManager from '@ohos.app.ability.missionManager';

let listener: missionManager.MissionListener = {
    onMissionCreated: (mission) => {
        console.log(`onMissionCreated mission: ${JSON.stringify(mission)}`);
    },
    onMissionDestroyed: (mission) => {
        console.log(`onMissionDestroyed mission: ${JSON.stringify(mission)}`);
    },
    onMissionSnapshotChanged: (mission) => {
        console.log(`onMissionSnapshotChanged mission: ${JSON.stringify(mission)}`);
    },
    onMissionMovedToFront: (mission) => {
        console.log(`onMissionMovedToFront mission: ${JSON.stringify(mission)}`);
    },
    onMissionLabelUpdated: (mission) => {
        console.log(`onMissionLabelUpdated mission: ' + ${JSON.stringify(mission)}`);
    },
     onMissionIconUpdated: (mission, icon) => {
        console.log(`onMissionIconUpdated mission: ' + ${JSON.stringify(mission)}`);
        console.log(`onMissionIconUpdated icon: ' + ${JSON.stringify(mission)}`);
     },
    onMissionClosed: (mission) => {
        console.log(`onMissionClosed mission: ${JSON.stringify(mission)}');
    }
};

try {
    let listenerId = missionManager.on('mission', listener);
} catch (paramError) {
    console.error(`error: ${paramError.code}, ${paramError.message}`);
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/e81793c337bd4972b5541bc20e00d092