在 Android 上模拟触摸屏事件 [英] Simulating Touch Screen Events on Android

查看:50
本文介绍了在 Android 上模拟触摸屏事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后台进程或软键盘是否可以创建触摸事件并将它们发送到屏幕,就像屏幕被实际触摸一样?

Is it possible for a background process or softkeyboard to create touch events and send them to screen as if the screen was actually touched?

即模拟触摸屏事件.

推荐答案

SDK 附带了一个工具,名为 Monkey 生成用户事件的伪随机流,例如:

There is a tool that comes with the SDK called Monkey which generates pseudo-random streams of user events such as:

  • 点击
  • 触摸
  • 手势
  • 许多系统级事件.

您可以使用 Monkey 以随机但可重复的方式对您正在开发的应用程序进行压力测试.

You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.

还有 monkeyrunner 工具,它提供了用于编写的 API从 Android 代码外部控制 Android 设备或模拟器的程序.使用monkeyrunner,您可以编写Python 程序来安装Android 应用程序或测试包、运行它、向其发送按键、截取其用户界面的屏幕截图并将屏幕截图存储在工作站上.

There is also the monkeyrunner tool which provides an API for writing programs that control an Android device or emulator from outside of Android code. With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation.

这篇关于在 Android 上模拟触摸屏事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆