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
>
--
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