Android模拟器取向变化通过模拟器控制台或亚洲开发银行 [英] Android Emulator Orientation Change Through Emulator Console or ADB

查看:138
本文介绍了Android模拟器取向变化通过模拟器控制台或亚洲开发银行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个自动化测试框架检查基本的东西,一个应用程序应该做出回应,没有崩溃。其中之一是检查,如果一个应用程序响应正确的配置变化。现在,因为它是自动的,我必须切换横向和纵向之间的仿真器的方向,观察它是否崩溃,编程。 [帽的Cuz有关于CTRL许多问题+ F12或数字键盘7]

我试图找出一个ADB或模拟器控制台命令来完成这件事。

我做一个telnet到localhost:5554,并输入以下命令:

  

$传感器状态//给所有传感器的启用/禁用状态

 加速度:启用。
磁场:启用。
方向:启用。
温度:启用。
接近:启用。
好
 

  

$传感器获得的方向

 方向= 0:0:0
 

  

$传感器设置定向90:0:0

 确定
 

我尝试了这种不同的组合,并没有作出回应。为了得到当它在横向模式下所设置的值,我手动更改使用Ctrl + F12的方向,并试图再次获得定位传感器的状态,和我沮丧的是,价值并没有改变。

某博客中也提到亚行这个特殊命令

  

$服务呼叫窗口18 I32 1

     

$服务呼叫窗口18 I32 0

切换方向。但是,我得到这个错误信息

  

结果:地块(FFFFFFFC FFFFFFFF'........')

这将是巨大的,如果我能得到一个解决这个。

解决方案

最后,我想出一个办法做到这一点。

首先,我会尝试澄清问题一点点:

通常人们谈论'旋转'的AVD的屏幕实际上意味着改变皮肤布局纵向/横向(平板电脑的模仿旋转)。这可以通过preSS做7/9数字键盘或preSS CTRL + FN + F12关键。在这种情况下,显示的方向不会改变,有时显示器将是恼人左到右或从右到左,以代替天然最多至底部。这可以通过在Android的设置取消勾选自动旋转来解决。

然而,在某些情况下,我们希望看到的重力传感器的效果。我觉得这其实是关系到OP的问题。不同的是GPS,还有就是Eclipse没有GUI工具来做到这一点。在OP是非常接近要解决的问题。然而,方位传感器是不正确的,我们需要使用重力/加速度传感器来自动旋转屏幕。 试试下面的命令,并与自动旋转观察显示方向上:

 传感器设定的加速9.77622:0:0
传感器设置加速度0:9.77622:0
传感器设定的加速0:0:9.77622
 

I am trying to build an automated test framework for checking basic things that an app should respond to, without crashing. One of those is checking if an app responds to configuration change properly. Now, since it is automated, I have to switch the emulator's orientation between landscape and portrait and observe if it crashes, PROGRAMMATICALLY. [caps cuz there are many questions relating to ctrl+F12 or num pad 7]

I am trying to figure out an adb or emulator console command to get this done.

i did a telnet to localhost:5554 and entered the following commands:

$sensor status // gives the enabled/disabled status of all sensors

acceleration: enabled.
magnetic-field: enabled.
orientation: enabled.
temperature: enabled.
proximity: enabled.
OK

$sensor get orientation

orientation = 0:0:0

$sensor set orientation 90:0:0

OK

I tried different combinations of this and it doesn't respond. To get the value that is set when it is in landscape mode, I manually changed the orientation using ctrl+F12 and tried getting the orientation sensor status again, and to my dismay, the value didn't change.

A certain blog also mentioned this particular command in ADB

$service call window 18 i32 1

$service call window 18 i32 0

for switching orientations. But, I get this error message

Result: Parcel(fffffffc ffffffff '........')

It would be great if I could get a solution to this.

解决方案

Finally I figure out a way to do it.

First I will try to clarify the question a little bit:

usually people talking about 'rotate' the AVD screen actually mean changing the skin layout to portrait/landscape (Mimic rotation of the tablet). Which can be done by press "7/9" key on number keypad or press ctrl+Fn+F12. In this case, the direction of the display will not change, sometimes the display will be annoying Left-to-right or right-to-left, in stead of natural up-to-bottom. This can be solved by uncheck the auto-rotation in android setting.

However, in some case we would like to see the effect of the gravity sensor. I think this is actually related to the OP's question. Unlike the GPS, there is no GUI tools of Eclipse to do this. The OP is very close to solve the problem. However, the orientation sensor is not the correct one, we need to use the gravity/acceleration sensor to rotate the screen automatically. try following command and observe the display direction with auto-rotation on:

sensor set acceleration 9.77622:0:0
sensor set acceleration 0:9.77622:0
sensor set acceleration 0:0:9.77622

这篇关于Android模拟器取向变化通过模拟器控制台或亚洲开发银行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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