harmony 鸿蒙MissionSnapshot

2022-12-22 浏览 (767)

MissionSnapshot

The MissionSnapshot module defines the snapshot of a mission. The snapshot can be obtained through getMissionSnapShot.

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. The APIs of this module are system APIs and cannot be called by third-party applications.

Modules to Import

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

Attributes

System capability: SystemCapability.Ability.AbilityRuntime.Mission

NameTypeReadableWritableDescription
abilityElementNameYesYesAbility information of the mission.
snapshotimage.PixelMapYesYesSnapshot of the mission.

How to Use

The mission snapshot information can be obtained by using getMissionSnapShot in missionManager.

Example

  import ElementName from '@ohos.bundle.bundleManager';
  import image from '@ohos.multimedia.image';
  import missionManager from '@ohos.app.ability.missionManager';

  try {
    missionManager.getMissionInfos('', 10, (error, missions) => {
      if (error) {
          console.error(`getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}`);
          return;
      }
      console.log(`size = ${missions.length}`);
      console.log(`missions = ${JSON.stringify(missions)}`);
      let id = missions[0].missionId;

      missionManager.getMissionSnapShot('', id, (err, snapshot) => {
        if (err) {
          console.error(`getMissionInfos failed, err.code: ${JSON.stringify(err.code)}, err.message: ${JSON.stringify(err.message)}`);
          return;
        }

        // Carry out normal service processing.
        console.log(`bundleName = ${snapshot.ability.bundleName}`);
      });
    });
  } 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/97f0828c1b5f4334ac69cb64b3701364