除了使用坐标之外,还有什么方法可以在monkeyrunner中打开wifi

发布于 2024-12-08 00:32:55 字数 232 浏览 0 评论 0原文

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

从 android.net.wifi 导入 WifiManger 将 android.jar 文件复制到 tool/lib 位置后可以正常工作。但是如何使用 Monkeyrunner/monkey 在 android fon 中调用 WifiManger 方法..?请有人帮忙。

Is there any way to switch on wifi in monkeyrunner otherthan using the cordinates.?Can we use WifiManager api from monkeyrunner.

from android.net.wifi import WifiManger
is working after copying android.jar file to tool/lib location.But how to invoke the WifiManger methods inside a android fon using monkeyrunner/monkey..??Somebody please help.

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

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

发布评论

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

评论(2

鱼窥荷 2024-12-15 00:32:55

您可以通过其他方式打开 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”KeyCode,您可以启用 wi-fi...!!!

You can switch on the wi-fi by another way. Start the activity of settings and go to the "wireless & network settings" and enable it.

Following code is the start the activity of the settings:

# 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)

After that by the press event use 'DOWN' and 'ENTER' KeyCode and you can enable the wi-fi...!!!

Oo萌小芽oO 2024-12-15 00:32:55

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

I looked into this exact issue a few months ago. It did not seem possible to me; at least easily. The best way I could find was to use startActivity to get as close to the wi-fi settings as possible, and then program in D-PAD commands until the correct field was highlighted. You may be able to use this logic to develop a small, purpose build, app that onCreate or onResume toggles wi-fi. In my case, it was not worth the amount of time this would have taken.

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