harmony 鸿蒙SysCap
SysCap
SystemCapability (SysCap) refers to a standalone feature in the operating system. Different devices support different SysCap sets. Each SysCap corresponds to one or more APIs. You can determine whether an API can be used by checking SysCap support.
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.
canIUse
canIUse(syscap: string): boolean
Checks whether a SysCap is supported.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
syscap | string | Yes | Name of the SysCap to check.Null and undefined inputs are not supported. |
Return value
Type | Description |
---|---|
boolean | Check result. The value true means that the SysCap is supported, and false means the opposite. |
Example
import { geoLocationManager } from '@kit.LocationKit'
import { BusinessError } from '@kit.BasicServicesKit';
const isLocationAvailable = canIUse('SystemCapability.Location.Location.Core');
if (isLocationAvailable) {
geoLocationManager.getCurrentLocation((err: BusinessError, location: geoLocationManager.Location) => {
if (err) {
console.error('err=' + JSON.stringify(err));
}
if (location) {
console.log('location=' + JSON.stringify(location));
}
});
} else {
console.log('Location not by this device.');
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙JSVM_CreateVMOptions
harmony 鸿蒙JSVM_ExtendedErrorInfo
harmony 鸿蒙JSVM_PropertyDescriptor
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦