Thanks Bill,

But this code for short press on POWER button isn't working. I tried with
emulator  (Android 1.6, Android 2.1) and also on Xperia device.  I also
tried with controlling duration of the press but it opens the Phone Options.
I wanted to simulate lock screen by pressing on POWER Button.

With this command [ *device.press('KEYCODE_POWER', 'down') *] you can  open
the dialogue box which gives the Phone options (Silent Mode, Airplane Mode
and Power off).

Is there any other way to simulate the lock screen?

Really Appreciate your help.

On Thu, Mar 3, 2011 at 4:30 PM, Bill Napier <[email protected]> wrote:

> This worked for me.  It turned off my Nexus S when I tried it.
>
> What you were doing was only sending the down part of the DOWN_AND_UP, so
> it was like you were pressing the POWER button and then never ever taking
> your finger off of it.
>
> If you want even more control over the duration of the press, you can do a
> DOWN, sleep for a bit, and then do the UP.  DOWN_AND_UP runs the commands
> with no delay in-between at all (a really short press).
>
> ----- code snipped -----
>
> from com.android.monkeyrunner import MonkeyRunner as mr
> from com.android.monkeyrunner import MonkeyDevice
>
> device = mr.waitForConnection()
>
> device.press("POWER", MonkeyDevice.DOWN_AND_UP)
>
>
> On Mon, Feb 28, 2011 at 11:56 AM, aniruddha dhamal <
> [email protected]> wrote:
>
>> I tried to use
>>
>> *device.press('KEYCODE_POWER', 'down')*
>>
>> but this works for long press on power button.
>>
>> Thanks,
>>
>>
>> On Sat, Feb 26, 2011 at 4:01 PM, Andya <[email protected]> wrote:
>>
>>> Hello guys,
>>>
>>> Any help on how to simulate short key press on Power button using
>>> MonkeyRunner?
>>>
>>> I am using the following code but to no avail
>>>
>>> device.press('KEYCODE_POWER','DOWN')
>>>
>>> Really appreciate!!!
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>>
>>
>> --
>> Thanks and Regards
>>
>> Aniruddha Dhamal
>> [email protected]
>>
>> " No matter which direction you start
>> Its always against the wind coming  back "
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>


-- 
Thanks and Regards

Aniruddha Dhamal
[email protected]

" No matter which direction you start
Its always against the wind coming  back "

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to