harmony 鸿蒙@ohos.systemCapability (SystemCapability)

  • 2023-02-03
  • 浏览 (334)

@ohos.systemCapability (SystemCapability)

System capability (SysCap) refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. This module provides APIs for querying the set of system capabilities.

NOTE

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

Modules to Import

import systemcapability from '@ohos.systemCapability'

systemcapability.querySystemCapabilities

querySystemCapabilities(callback: AsyncCallback<string>): void;

Queries system capabilities. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Developtools.Syscap

Parameters

Name Type Mandatory Description
callback AsyncCallback Yes Callback invoked to return the result.

Example

try {
    systemcapability.querySystemCapabilities((err:Error, data:string) => {
    if (err == undefined) {
        console.log("get system capabilities:" + data)
    } else {
        console.log(" get system capabilities err:" + err)
    }});
}catch(e){
    console.log("get unexpected error: " + e);
}

systemcapability.querySystemCapabilities

querySystemCapabilities(): Promise<string>

Queries system capabilities. This API uses a promise to return the result.

System capability: SystemCapability.Developtools.Syscap

Return value

Type Description
Promise<string> Promise used to return the result.

Example

try {
    systemcapability.querySystemCapabilities().then((value:string) => {
        console.log("get system capabilities: " + value);
    }).catch((err:Error) => {
        console.log("get system capabilities error: " + err);
    });
}catch(e){
    console.log("get unexpected error: " + e);
}

NOTE

The system capabilities returned by the preceding APIs are in the form of an encoded numeric string.

你可能感兴趣的鸿蒙文章

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)

0  赞