Search code examples
androidmonkeyrunner

How to check status of android phone screen is locked or unlocked using monkeyrunner


i want to know how to get the status of android phone screen whether its locked or unlocked using monkeyrunner . please help .

Thanks in advance


Solution

  • Using AndroidViewClient (>= 4.7.0) (which uses python instead of monkeyrunner`) you can do

    from com.dtmilano.android.viewclient import ViewClient
    
    device, serialno = ViewClient.connectToDeviceOrExit()
    if device.isLocked():
        device.wake()
        device.unlock()