目录

Screen Lock (1090+)

API Declaration

Add the following configuration to the features attribute in the manifest.json file:

{"name": "system.keyguard"}

Module Import

Add the following configuration to the script element on the page where the API will be called:

import keyguard from '@system.keyguard'

Or

var keyguard = require("@system.keyguard")

Application Scope

Item

Description

Applicable devices

Mobile phones, tablets, Vision products, and telematics devices

Applicable regions

Global

Definition

API

Description

keyguard.getKeyguardLockedStatus(OBJECT)

Checks whether the device screen is locked.

[h2]keyguard.getKeyguardLockedStatus(OBJECT)

Description

Checks whether the device screen is locked.

OBJECT

Parameter

Type

Mandatory

Description

success

function

No

Success callback that returns an object.

fail

function

No

Failure callback that returns a result code and an error message.

Parameters returned by success

Parameter

Type

Description

isKeyguardLocked

boolean

  • true: The screen is locked.
  • false: The screen is not locked.

Sample code

import keyguard from '@system.keyguard'
export default {
  onShow() {
    keyguard.getKeyguardLockedStatus({
      success: result => {
        console.log('Is the current application locked : ', result.isKeyguardLocked)
      },
      fail: (data, code) => {
        console.log(`get isKeyguardLocked fail, errMsg = ${data}`)
        console.log(`get isKeyguardLocked fail, errCode = ${code}`)
      }
    })
  }
}

Version Change History

Version

Date

Description

1090

2022-05-19

First official version.