• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.systemCapability (SystemCapability)
2
3System 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.
4
5> **NOTE**
6>
7> - 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.
8>
9> - The APIs provided by this module are system APIs.
10
11
12## Modules to Import
13
14```ts
15import systemcapability from '@ohos.systemCapability'
16```
17
18## systemcapability.querySystemCapabilities
19
20querySystemCapabilities(callback: AsyncCallback<string>): void;
21
22Queries system capabilities. This API uses an asynchronous callback to return the result.
23
24**System capability**: SystemCapability.Developtools.Syscap
25
26**Parameters**
27
28| Name| Type| Mandatory| Description|
29| -------- | -------- | -------- | -------- |
30| callback | AsyncCallback<string> | Yes| Callback invoked to return the result.|
31
32
33**Example**
34
35```ts
36try {
37    systemcapability.querySystemCapabilities(function (err, data) {
38    if (err == undefined) {
39        console.log("get system capabilities:" + data)
40    } else {
41        console.log(" get system capabilities err:" + err.code)
42    }});
43}catch(e){
44    console.log("get unexpected error: " + e);
45}
46```
47
48
49## systemcapability.querySystemCapabilities
50
51querySystemCapabilities(): Promise&lt;string&gt;
52
53Queries system capabilities. This API uses a promise to return the result.
54
55**System capability**: SystemCapability.Developtools.Syscap
56
57**Return value**
58
59| Type| Description|
60| -------- | -------- |
61| Promise&lt;string&gt; | Promise used to return the result.|
62
63**Example**
64
65```ts
66try {
67    var p = systemcapability.querySystemCapabilities();
68    p.then(function (value) {
69        console.log("get system capabilities: " + value);
70    }).catch(function (err) {
71        console.log("get system capabilities error: " + err.code);
72    });
73}catch(e){
74    console.log("get unexpected error: " + e);
75}
76```
77
78
79> **NOTE**
80>
81> The system capabilities returned by the preceding APIs are in the form of an encoded numeric string.
82