Android 2.3的模拟器方向更改模拟器、方向、Android

2023-09-04 09:06:32 作者:迩、优美的姿态

我遇到了一个有点问题,我认为这是关系到仿真器本身。我已经把这个code就在我的的onCreate 方法的顶部在我的活动之一:

I ran into a bit of a problem, which I think is related to the emulator itself. I have put this code right at the top of my onCreate method in one of my activities:

Log.d(Const.TAG, "onCreate orientation: " + getRequestedOrientation());

每次我在模拟器中进行切换方向(通过按Ctrl + F11和/或民7),它打印 1 (相当于SCREEN_ORIENTATION_UNSPECIFIED),它卡在横向(不切换到肖像,除非我重新启动应用程序)。

Everytime I switch orientation in the emulator (via Ctrl+F11 and/or Num 7), it prints -1 (which corresponds to SCREEN_ORIENTATION_UNSPECIFIED), and it gets stuck in landscape (doesn't switch back to portrait unless I relaunch the app).

我是不是做错了什么?是其他任何人有这个问题?它是严格相关的2.3模拟器有问题或是否出现在器件(歌Nexus S目前)呢?

Am I doing something wrong? Is anyone else having this problem? Is it a problem related strictly to the 2.3 emulator or does it appear on devices (Nexus S currently) as well?

推荐答案

这似乎是与模拟器有问题,因为设置应用程序(例如)做同样的事情(尽管启动不,这使我相信启动应用程序使用一些其他的机制来检测方向改变)。

It seems to be a problem with the emulator, since the Settings app (for example) does the same thing (although the Launcher doesn't, which leads me to believe the Launcher app uses some other mechanism to detect orientation changes).

我要纪念这个答案,因为接受了两天,在此之前请随时免费的,如果你有一些启发。

I'll mark this answer as accepted in a couple days, until then please feel free to shed some light if you have it.