1# @ohos.systemCapability (系统能力)(系统接口) 2 3系统能力(SystemCapability,简称SysCap),指操作系统中每一个相对独立的特性。不同的设备对应不同的系统能力集,每个系统能力对应多个接口。开发者可根据系统能力来判断是否可以使用某接口。本模块提供接口可查询系统能力的集合。 4 5> **说明:** 6> 7> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> - 本模块接口为系统接口。 9 10 11## 导入模块 12 13```ts 14import systemcapability from '@ohos.systemCapability'; 15``` 16 17## systemcapability.querySystemCapabilities 18 19querySystemCapabilities(callback: AsyncCallback<string>): void; 20 21获取系统能力集合的字符串,并调用回调函数。 22 23**系统能力:** SystemCapability.Developtools.Syscap 24 25**参数:** 26 27| 参数名 | 类型 | 必填 | 说明 | 28| -------- | -------- | -------- | -------- | 29| callback | AsyncCallback<string> | 是 | 回调函数 | 30 31 32**示例:** 33 34```ts 35try { 36 systemcapability.querySystemCapabilities((err:Error, data:string) => { 37 if (err == undefined) { 38 console.log("get system capabilities:" + data) 39 } else { 40 console.log(" get system capabilities err:" + err) 41 }}); 42}catch(e){ 43 console.log("get unexpected error: " + e); 44} 45``` 46 47 48## systemcapability.querySystemCapabilities 49 50querySystemCapabilities(): Promise<string> 51 52获取系统能力的集合。 53 54**系统能力:** SystemCapability.Developtools.Syscap 55 56**返回值:** 57 58| 类型 | 说明 | 59| -------- | -------- | 60| Promise<string> | Promise示例,用于异步获取结果。 | 61 62**示例:** 63 64```ts 65try { 66 systemcapability.querySystemCapabilities().then((value:string) => { 67 console.log("get system capabilities: " + value); 68 }).catch((err:Error) => { 69 console.log("get system capabilities error: " + err); 70 }); 71}catch(e){ 72 console.log("get unexpected error: " + e); 73} 74``` 75 76 77> **说明:** 78> 79> 以上接口所返回的system capability集合形式均为编码后的数字字符串形式。 80 81 82