Android,如何在AVD中模拟滑动手势?

发布于 2024-11-28 01:40:53 字数 227 浏览 3 评论 0原文

如何在 AVD 上模拟滑动手势(例如向左和向右)? 有可能吗? (在 Android 开发人员指南 - 模拟器 我找不到它们...

PS:我确实在 Android 2.2、API 级别 8 设备设置中将“触摸屏支持”设置为“是”

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

格子衫的從容 2024-12-05 01:40:53

只需单击并按住并移动鼠标即可创建所需的动作。

Just click and hold and move the mouse to created the desired motion.

傾城如夢未必闌珊 2024-12-05 01:40:53

一种更简单的方法是录音和播放。

而不是处理 getevent 的命令输出,然后发送将结果发送到 sendevent 的速度非常慢。我设法从与我的 AVD 具有相同 Android 版本的真实设备上盲目记录手势,然后将记录的数据流式传输到输入缓冲区,这成功地欺骗了设备。

您可以通过以下方式复制真实设备的触摸输入:

  1. 使用 dd< /code>命令,在 adb shell 中运行 dd if=/dev/input/event2 of=/sdcard/left。这会将所有触摸输入数据缓冲到 /sdcard/left 文件。

  2. 执行您想要模拟的手势(滑动)。

  3. 现在,(/sdcad/left) 已由您真实触摸生成的数据填充。您可以退出 dd 命令 (ctrl + c)。

  4. 将文件从真实设备移动到 AVD 中的任意位置,例如 (/sdcad/left)

  5. 在 AVD adb shell 中,运行 dd if=/sdcard/left of=/dev/input/event2

中提琴!模拟的触摸事件将会发生。

注意:在我的设备中,具有触摸事件的文件是 /dev/input/event2 ,它可能因设备而异,因此您可以先尝试和错误。 >


简而言之,如果您在同一设备上录制和播放:

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

  2. 真实触摸

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

  4. 根据需要重复步骤 3。

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.

云仙小弟 2024-12-05 01:40:53

您可以使用 adb shell getevent 和 adb shel sendevent 记录输入事件并在模拟器上重放它们,有点难以理解,并且需要将 getevent 输出的十六进制值转换为十进制,但非常有用。

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.

九命猫 2024-12-05 01:40:53

tl;dr:我想您可能会觉得它不起作用,因为问题在于它使用户输入处理在线速度非常慢。如果你弄乱它 10 分钟,但它仍然不起作用,那么就有问题了 - 但请先给它 10 分钟。

这是我的经验,以便您可以了解我是如何得出这个结论的:

我从未明确地将设备添加到 AVD 管理器 - Studio 为我添加了它。

当我运行我的(Hello World)应用程序时,花了相当长的时间才出现 - 首先似乎没有发生任何事情,所以我单击 Studio 窗口底部的“Android”,发现它正在记录它正在做的事情。

仍然有许多延误。大约一分钟后,模拟器弹出,并显示一条有关丢失备份或类似信息的消息。又过了大约一分钟,我看到上面写着“正在充电”,于是我点击并拖动,但什么也没发生。我又尝试了几次,最后它通过将“充电”更改为“滑动解锁”来做出响应(我认为 - 类似的东西)。所以我又尝试了几次单击拖动,但似乎没有记录拖动。最后,我注意到当我将鼠标悬停在相机(软件)按钮上时,它会亮起,所以我单击了它,然后我进入了相机(不确定是否是通过拖动或单击白色圆圈中的小<),然后从在那里我可以做一些事情。

tl;dr: I think you might feel that it doesn't work when the problem is that it's just really slow bringing the user-input processing online. If you mess with it for 10 minutes and it still doesn't work, then there's something wrong - but give it the 10 minutes first.

Here's my experience so you can see how I came to that conclusion:

I never explicitly added a device to the AVD Manager - Studio added it for me.

When I ran my (Hello World) app, it took quite a while to come up - first nothing seemed to be happening, so I clicked on "Android" at the bottom of Studio's window and found that it was logging what it was doing.

There were still numerous delays. A minute or so later, the emulator popped up and it had a message about missing a backup or something like that. Another minute or so later, I saw that it said "Charging", so I clicked and dragged but nothing happened. I tried that a few more times and finally it responded by changing "Charging" to "Swipe to unlock" (I think - something like that). So I tried the click-drag a few more times but it didn't seem to register the drag. Finally I noticed the camera (software) button light up when I moused over it, so I clicked it, then I got into the camera (not sure if it was by dragging or clicking the little < in the white circle), and from there I could do stuff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文