0

除了使用坐标之外,还有什么方法可以在monkeyrunner中打开wifi。我们可以使用monkeyrunner的WifiManager api吗?

from android.net.wifi import WifiManger 在将 android.jar 文件复制到工具/lib 位置后正在工作。但是如何使用 monkeyrunner/monkey 在 android fon 中调用 WifiManger 方法..?有人请帮忙。

4

2 回答 2

1

您可以通过其他方式打开 wi-fi。启动设置活动并转到“无线和网络设置”并启用它。

以下代码是设置的启动活动:

# sets a variable with the package's internal name
package = 'com.android.settings'

# sets a variable with the name of an Activity in the package
activity = 'com.android.settings.Settings'

# sets the name of the component to start
runComponent = package + '/' + activity

setting = 'com.android.settings.Settings'

print("")
print("")
print("Start the Activity...")

# Runs the component
device.startActivity(component=runComponent)

之后通过新闻事件使用“DOWN”和“ENTER”键码,您可以启用wi-fi ...!!!

于 2011-10-13T07:33:19.307 回答
0

几个月前我研究了这个确切的问题。这对我来说似乎不可能;至少很容易。我能找到的最好方法是使用 startActivity 尽可能接近 wi-fi 设置,然后在 D-PAD 命令中编程,直到突出显示正确的字段。您也许可以使用此逻辑来开发一个小型的专用构建应用程序,该应用程序可通过 onCreate 或 onResume 切换 wi-fi。就我而言,这不值得花这么多时间。

于 2011-10-03T21:57:51.253 回答