harmony 鸿蒙@ohos.systemCapability (System Capability) (System API)

  • 2025-06-12
  • 浏览 (4)

@ohos.systemCapability (System Capability) (System API)

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<string> Yes Callback used 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 鸿蒙Basic Services Kit

harmony 鸿蒙DeviceInfo

harmony 鸿蒙InitSync

harmony 鸿蒙OH_Print

harmony 鸿蒙OsAccount

harmony 鸿蒙Pasteboard

harmony 鸿蒙Print_Margin

harmony 鸿蒙Print_PageSize

harmony 鸿蒙Print_PrintAttributes

harmony 鸿蒙Print_PrintDocCallback

0  赞