简体   繁体   English

从命令行更改Android设备方向

[英]Changing Android device orientation from command line

I am running a series of automated tests on Android devices which are hosted in html pages on a local server. 我正在Android设备上运行一系列自动化测试,这些设备托管在本地服务器上的html页面中。 Some of the tests need to be run in Portrait, some in landscape. 有些测试需要在Portrait中运行,有些需要在横向上运行。 I am trying to find the way to check and change the orientation of the device or the browser programmatically. 我试图找到以编程方式检查和更改设备或浏览器方向的方法。

Currently I am writing in Python/Jython/Monkeyrunner/ADB but I could switch if there were a good solution to this from some other source. 目前我正在使用Python / Jython / Monkeyrunner / ADB编写,但如果有其他来源的解决方案,我可以切换。

a basic test would be run: 将运行基本测试:

check orientation/change orientation open url activate test on page get results repeat 检查方向/更改方向打开网址激活测试页面获取结果重复

I have tried "service call window 18 i32 1", which would be ideal for my purposes, but I only get errors, ie "Result: Parcel(fffffffc ffffffff '........')" 我试过“服务电话窗口18 i32 1”,这对我来说是理想的,但我只会得到错误,即“结果:包裹(fffffffc ffffffff'........')”

Is there a way to call this as an activity of the browser/android? 有没有办法把它称为浏览器/ android的活动? Is there a way to spoof tilt events to trigger the change? 有没有办法欺骗倾斜事件来触发变化? Could this be done from within an app, installed and run as a package? 这可以在应用程序中完成,安装并作为包运行吗?

Sorry, it seems I wasn't clear. 对不起,似乎我不清楚。 I will not be using an emulator but rather a series of actual android devices, hooked in through the USB. 我不会使用模拟器,而是一系列实际的Android设备,通过USB连接。 Any help on this topic would be appreciated, including knowing for sure that there is no pre-defined method for this to happen. 关于这个主题的任何帮助都将受到赞赏,包括确定没有预定义的方法来实现这一点。 Thanks, 谢谢,

You can change emulator orientation when emulator is focused if you press Ctrl+F11 or KEYPAD_7. 如果按Ctrl + F11或KEYPAD_7,则可以在仿真器聚焦时更改仿真器方向。 More emulator options here http://developer.android.com/guide/developing/tools/emulator.html 这里有更多模拟器选项http://developer.android.com/guide/developing/tools/emulator.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM