该方法被调用。
onConfigurationChanged
将被系统调用。
@Override
public void onConfigurationChanged(Configuration myConfig) {
super.onConfigurationChanged(myConfig);
int orient = getResources().getConfiguration().orientation;
switch(orient) {
case Configuration.ORIENTATION_LANDSCAPE:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case Configuration.ORIENTATION_PORTRAIT:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
default:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}
如果我的应用程序尚未启动,是否会调用此方法?我真正需要的是我的应用程序在方向更改时醒来(或开始)。 – 2012-04-28 08:58:02
阅读[this](http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged(android.content.res.Configuration))和[this](http://developer.android。 com/guide/topics/resources/runtime-changes.html) – Rafiq 2012-04-28 09:12:20
我在发布问题之前已阅读过这些内容。他们表示:“当您的活动正在运行时,设备配置发生变化时由系统调用。”所以,如果我的应用程序没有运行,该方法将不会被调用。有我的解决方案吗? – 2012-04-28 09:19:25