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:

  1. Using dd command, in adb shell run dd if=/dev/input/event2 of=/sdcard/left. This will buffer all the touch input data to /sdcard/left file.

  2. Do the gesture you like to simulate (swipe).

  3. Now that (/sdcad/left) is populated by the data generated by your real touch. You can exit the dd command (ctrl + c).

  4. Move the file from you real device to any location in your AVD, lets say (/sdcad/left).

  5. 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:

  1. dd if=/dev/input/event2 of=/sdcard/left

  2. Do the touch for real

  3. dd if=/sdcard/left of=/dev/input/event2

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