Skip to main content
Version: v2

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

PropertyTypeDescriptionAPI_LEVEL
widthnumberDevice screen width2.0
heightnumberDevice screen height2.0
screenShapenumberScreen shape, value refer to screen shape constants2.0
deviceNamenumberDevice name2.0
keyNumbernumberNumber of keys2.0
deviceSourcenumberDevice Plain Numeric Designators2.0
keyTypestringDevice physical button type2.0
deviceColornumberDevice color identification2.0

Constants

Screen shape

ConstantDescriptionAPI_LEVEL
SCREEN_SHAPE_SQUARESquare Screen2.0
SCREEN_SHAPE_ROUNDRound Screen2.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')
}