对于我的项目,我需要做以下事情,
- 通过 adb getevent 命令获取设备触摸事件。
- 同时我需要找到一些东西来收集应用程序 Activity 调用的信息。
我的目标是找出每次触摸信息时特定应用程序中的 Activity 是否发生变化,并检测该 Activity 。
因此,每当在 (x,y) 位置发生触摸时,getevent 都会报告,现在如果该位置上有一个按钮,它可能会调用应用程序中的 Activity 更改,因此我需要检测新 Activity 的更改。
如何做到这一点?有什么想法吗?
最佳答案
您可以在 python 脚本中尝试此操作:
from subprocess import call
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
# These show the package name of the currently running package and
# the current activity's action.
device.getProperty('am.current.package')
device.getProperty('am.current.action')
使用monkeyrunner,您还可以使用(x,y)坐标单击/按下按钮。
另一种方法是在 logcat 输出中查找 Activity 更改。它应该看起来像这样: Displayed com.android.gallery3d/.app.MovieActivity Whyen Playing a video file from gallery.
稍后编辑:
您可以使用“am.current.package”和“am.current.action”来查看 Activity 的变化。您可以使用:
call('adb getevent', shell = True)
捕获点击/触摸事件。全部都在同一个脚本中。
关于android - 如何将 android Activity 更改与 adb getevent 命令链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12220463/