Thursday, November 26, 2009

[android-developers] How to get the current activity window in java program?

hi, all

i want to write a java program like monkey to test my activity.


like below, i can make a click at the coordinate, but i can not know the button's coordinate which i want to click.

           WindowManager windowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
            windowManager.injectPointerEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),
                        SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 240, 400, 0), true);
            windowManager.injectPointerEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),
                        SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 240, 400, 0), true);       

so, i wonder if i can get the current activity window, then i can use findViewById to get the button, but how?

thanks~

--
Bear ^O^

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate