Skip to main content

screenLocked

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read whether the screen is locked, or lock and unlock it. These call app_lock.

screenLocked​

public boolean screenLocked()
public boolean screenLocked(boolean locked)

Whether the screen is locked.

@return true when the screen is locked

Locks or unlocks the screen, confirmed against the device. A state rather than a power-button press: power is a toggle, so asking twice leaves the device where it started. A device with a PIN, pattern or password cannot be unlocked from outside and throws.

@param locked true to lock, false to unlock @return whether the screen is locked now, as read back

Examples​

Lock the screen​

boolean locked = device.screenLocked(true); // true, read back

Unlock it​

device.screenLocked(false);