您的位置:首页 > 移动开发 > Android开发

android:configChanges="orientation|keyboardHidden|screenSize"真的能固定屏幕吗

2016-08-19 10:43 495 查看
    之前固定屏幕一直用的
android:screenOrientation="portrait"


android:screenOrientation="landscape"

今天在activity改变配置销毁重启与被系统杀死重启时,看见很多人说android:configChanges="orientation|keyboardHidden|screenSize"可以固定屏幕

而我在Activity源码中看到了这么一段话

/**
* Called by the system when the device configuration changes while your
* activity is running.  Note that this will <em>only</em> be called if
* you have selected configurations you would like to handle with the
* {@link android.R.attr#configChanges} attribute in your manifest.  If
* any configuration change occurs that is not selected to be reported
* by that attribute, then instead of reporting it the system will stop
* and restart the activity (to have it launched with the new
* configuration).
*
* <p>At the time that this function has been called, your Resources
* object will have been updated to return resource values matching the
* new configuration.
*
* @param newConfig The new device configuration.
*/
public void onConfigurationChanged(Configuration newConfig) {
if (DEBUG_LIFECYCLE) Slog.v(TAG, "onConfigurationChanged " + this + ": " + newConfig);
mCalled = true;

mFragments.dispatchConfigurationChanged(newConfig);

if (mWindow != null) {
// Pass the configuration changed event to the window
mWindow.onConfigurationChanged(newConfig);
}

if (mActionBar != null) {
// Do this last; the action bar will need to access
// view changes from above.
mActionBar.onConfigurationChanged(newConfig);
}
}

然而我把那三个配置写上去的时候,事实证明除了能接受到
onConfigurationChanged回调后吊用没有,试了一个4.4一个5.1系统都还是转来转去,但是却并没有重启 没有重新调用onCreate和onDestroy方法
。。
原因现在还不清楚,,群众中间有坏人啊 人云亦云的扯淡
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐