Android : How can I inject pinch or zoom out events with instrumentation?

on Friday, December 12, 2014


I can catch all the motionevent when user does pinch or zoom out to a webview(loaded a google map in webview) on TabletA. I want to replay those motionevent on a webview on tabletB. I passed all the parameters of motionevent to tabletB and restored those motionevent with these parameters. My code looks like below:



m_Instrumentation.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(),MotionEvent.ACTION_DOWN,pozx, pozy, 0);m_Instrumentation.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(),MotionEvent.ACTION_UP,pozx, pozy, 0);


Actually, I referred to this link to implement this functionality(method): http://www.pocketmagic.net/2012/04/injecting-events-programatically-on-android/#.VIsp6PldWg9


My concern is how can I replay pinch and zoom out with method 2? the simple motionevent like click, doubleclick, move worked fine. pinch and zoom out or zoom in didn't work.


Any suggestions or do you have any better solutions?


Thanks


0 comments:

Post a Comment