this worked for me (on Nexus S):

from com.android.monkeyrunner import MonkeyRunner
from com.android.monkeyrunner import MonkeyDevice

dev = MonkeyRunner.waitForConnection()
dev.press('POWER', MonkeyDevice.DOWN)

It brought up the "Phone Options" menu.  I really recommend that you use the
constants inside MonkeyDevice to specify what kind of press you want, as no
guarantee is provided on their values.  If you refer to them as
MonkeyDevice.DOWN_AND_UP, that will always work.

On Tue, Apr 26, 2011 at 2:33 AM, Harrison 冯兴强 <[email protected]>wrote:

> Hi,
>
> I am using Monkeyrunner to do some automation testing  on my apps. But it
> didn't seem that this is long press solution on power key. As we know, we
> can get "Phone options" menu with "Silent mode", "Airplane mode", "Power
> off" when we long press hard power key manually. But when i use the
> following statement:
>
> device.press("KEYCODE_POWER","DOWN")
>
> I am not able to get the expected "Phone options" menu, I got the screen
> locked. That's  to say, the same result in using the following statement:
>
> device.press("KEYCODE_POWER","DOWN_AND_UP")
>
> So I can come to conclusion the MonkeyRunner API is not really to get long
> press hard key implemented. And I can see there is method
> performedLongPress<http://androidappdocs.appspot.com/reference/android/view/KeyEvent.DispatcherState.html#performedLongPress%28android.view.KeyEvent%29>
> (KeyEvent<http://androidappdocs.appspot.com/reference/android/view/KeyEvent.html>event)
>  from android.view.KeyEvent.DispatcherState to handle long press key.
>
> so can we have this in MonkeyRunner API in the incoming release version?
>
> Thanks
>
> Harrison Feng
> *
> *
>
>  --
> 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

Reply via email to