Add the following configuration to the features attribute in the manifest.json file:
{"name": "system.keyguard"} 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") Item | Description |
|---|---|
Applicable devices | Mobile phones, tablets, Vision products, and telematics devices |
Applicable regions | Global |
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 |
|
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}`)
}
})
}
}