我在我的应用程序有活动,我已经设置机器人:configChanges =“方向”我menifest文件是这样的:活动重启问题
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
和方法来处理它:
@Override
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
} else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
}
}
在大多数谷歌搜索我看到它说它会阻止重新启动我的活动,但它开始于方向changed.I把一个System.out ....内onCreate()它是打印每个orie这意味着它开始创作。任何帮助为什么它发生或我在哪里错了?
“如果你的应用程序的目标API级别13或更高(如通过中的minSdkVersion和targetSdkVersion属性声明),那么你也应该申报‘屏幕尺寸’的配置,因为当设备在纵向和横向之间切换时,它也会发生变化。“ - 也许这就是问题所在? – 2012-04-09 10:08:36
@appserv没有像我的最低4和目标为8 – 2012-04-09 10:12:56
PLZ看到这篇文章可能帮助完整:http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android – 2012-04-09 10:13:06