Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android, how to emulate swipe gestures in AVD?

How do I simulate swipe gestures (left and right, for example) on AVD? Is it possible at all? (In Android Developer's Guide - Emulator I can't find them...

P.S.: I do have "Touch-screen support" set to "yes" in my Android 2.2, API level 8 device settings

like image 497
MarcoS Avatar asked Aug 03 '11 21:08

MarcoS


1 Answers

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.

like image 69
Omar Alshaker Avatar answered Sep 23 '22 07:09

Omar Alshaker