android 竖屏activity跳转横屏activity返回时数据消失

android竖屏activity切换到横屏activity后返回会重现调用oncreate方法 导致页面异常

解决办法:

竖屏activity添加

android:configChanges="orientation|screenSize|keyboardHidden"
 
  
代码里重写
 
  
@Override
public void onConfigurationChanged(Configuration newConfig) {
    // TODO Auto-generated method stub
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        // Nothing need to be done here

    } else {
        // Nothing need to be done here
    }
}

你可能感兴趣的:(android 竖屏activity跳转横屏activity返回时数据消失)