Android, how to emulate swipe gestures in AVD?
Just click and hold and move the mouse to created the desired motion.
One easier way is recording and playing.
Instead of processing getevent
's command output, then sending your results to sendevent
which is really slow. I managed to blindly record the gestures from a real device with the same Android version as my AVD, then streamed the recorded data to the input buffer, this succeeded to fool the device.
You can copy the touch input of a real device by:
Using
dd
command, in adb shell rundd if=/dev/input/event2 of=/sdcard/left
. This will buffer all the touch input data to/sdcard/left
file.Do the gesture you like to simulate (swipe).
Now that
(/sdcad/left)
is populated by the data generated by your real touch. You can exit thedd
command (ctrl + c).Move the file from you real device to any location in your AVD, lets say
(/sdcad/left)
.In AVD adb shell, run
dd if=/sdcard/left of=/dev/input/event2
Viola! the simulated touch event will happen.
NOTE: In my device the file which has touch events is /dev/input/event2
, it might differ from a device to another, so you may use trial and error first.
In short, if you record and play on the same device:
dd if=/dev/input/event2 of=/sdcard/left
Do the touch for real
dd if=/sdcard/left of=/dev/input/event2
Repeat step 3, as much as you need.
You can record input event and replay them on the emulator, by using the adb shell getevent and adb shel sendevent, a bit hard tounderstand, and requires to translate the hex values of getevent output to decimal, but very usefull.