getDeviceInfo
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Gets device information.
info
permission code: data:os.device.info
Type
function getDeviceInfo(): Result
Parameters
Result
Property | Type | Description | API_LEVEL |
---|---|---|---|
width | number | Device screen width | 2.0 |
height | number | Device screen height | 2.0 |
screenShape | number | Screen shape, value refer to screen shape constants | 2.0 |
deviceName | number | Device name | 2.0 |
keyNumber | number | Number of keys | 2.0 |
deviceSource | number | Device Plain Numeric Designators | 2.0 |
keyType | string | Device physical button type | 2.0 |
deviceColor | number | Device color identification | 2.0 |
Constants
Screen shape
Constant | Description | API_LEVEL |
---|---|---|
SCREEN_SHAPE_SQUARE | Square Screen | 2.0 |
SCREEN_SHAPE_ROUND | Round Screen | 2.0 |
Example
import { getDeviceInfo, SCREEN_SHAPE_SQUARE } from '@zos/device'
const { width, screenShape } = getDeviceInfo()
console.log(width)
if (screenShape === SCREEN_SHAPE_SQUARE) {
console.log('Square Screen')
}