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

    之前固定屏幕一直用的
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方法
。。
原因现在还不清楚,,群众中间有坏人啊 人云亦云的扯淡

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值