Get the App
SLTechnology News&Howtos  ›  Development  › 

How to judge whether to lock the screen state

Shulou Source: shulou.com Published: 2022-06-03 06:53:44 09月17日 Update

This article introduces the relevant knowledge of "how to judge whether to lock the screen or not". In the course of the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The function that autojs does not judge whether there is a lock screen state needs to use the function that comes with Android, which is judged by the way autojs calls js. The code is as follows

Whether function locks screen () {importClass (android.app.KeyguardManager) importClass (android.content.Context) var km = context.getSystemService (Context.KEYGUARD_SERVICE); / / ture- lock screen, false- has unlocked return km.isKeyguardLocked ();} console.log ("lock screen:" + whether to lock screen ())

Determine if there is a lock screen password:

Whether function contains lock screen password () {importClass (android.app.KeyguardManager) importClass (android.content.Context) var km = context.getSystemService (Context.KEYGUARD_SERVICE); / / true: lock screen password (including SIM card lock) false: no return km.isKeyguardSecure ();} console.log ("lock screen password:" + whether lock screen password is included ())

Output result:

05-07 10 Script-318 Main 361.343 Script-318 Main [[remote] main.js] / D: whether the screen is locked or not: true 05-07 10 main.js 36V 01.344 Script-318 Main [[remote] main.js] / D: whether it contains the lock screen password: true "how to determine whether the lock screen status" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Passwords status content functions more knowledge output practicality learning next code dilemma reality situation articles methods cases results editing website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker Huawei Redmi MySQL