Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ADB to send touch events to device using sendevent command?

I am trying to send touch events to a device using AndroidDebugBridge, so that I can do some basic automation for UI tests. I have followed the discussion in LINK. I am able to use sendevent to simulate touch on emulators, but unable to do the same on a device.

Like in above link the emulator seems to send out 6 events for each touch ( xcoord, ycoord, 2 for press,2 for release) and it was easy to use this information to sendevents, but a getevent for the touchscreen for a device seems to generate far too many events.

Has somebody managed to send touch from ADB to a device? Could you please share the solution.

like image 580
Harkish Avatar asked Aug 09 '10 06:08

Harkish


People also ask

How do I launch an activity from adb?

You can use the start command from Activity Manager (am) a.k.a the adb shell am start -n command (via adb) specifying the app package name and the component name as defined in the manifest. You can add other parameters like ACTION (-a android. intent. action.

What is adb pull command?

This command is used to copy files and directories from an Android device. adb pull -a /fileLocation/fileName. Preserves the filestamp and mode while copying adb pull -a /mnt/sdcard/Download/test.apk.


1 Answers

Android comes with an input command-line tool that can simulate miscellaneous input events. To simulate tapping, it's:

input tap x y 

You can use the adb shell ( > 2.3.5) to run the command remotely:

adb shell input tap x y 
like image 55
user643154 Avatar answered Sep 21 '22 17:09

user643154