横竖屏切换时,禁止activity重新创建,android:configChanges="keyboardHidden|orientation" 不起作用

本文探讨了AndroidManifest.xml中android:configChanges属性的正确用法。指出在不同Android版本上该属性的效果差异,并强调了在4.0及以上版本中必须包含screenSize才能确保应用适配各种屏幕尺寸的变化。

这个网上搜索,很多结果都是:

AndroidManifest.xml
android:configChanges="keyboardHidden|orientation"


但是,实际上很多手机上,这个根本不起作用。这是为什么呢?

因为,但多数人陈陈相因,文章直接转,都没有结果自己实践。

在低版本上,这个是可以起作用。在android 4.0 以上实际上这个是不起作用的。

必须要加上screenSize。


android:configChanges="keyboardHidden|orientation|screenSize"



<activity android:configChanges="keyboardHidden|orientation" android:name="com.shenma.tvlauncher.SettingActActvity" android:screenOrientation="landscape"/> <activity android:configChanges="keyboardHidden|orientation" android:name="com.shenma.tvlauncher.SettingWallpaperActivity" android:screenOrientation="landscape"/> <activity android:configChanges="keyboardHidden|orientation" android:name="com.shenma.tvlauncher.TopicActivity" android:screenOrientation="landscape"/> <activity android:configChanges="keyboardHidden|orientation" android:name="com.shenma.tvlauncher.EmpowerActivity" android:screenOrientation="landscape"/> <activity android:configChanges="keyboardHidden|orientation" android:name="com.shenma.tvlauncher.HistoryActivity" android:screenOrientation="landscape"/> <activity android:configChanges="keyboardHidden|orientation" android:name="com.shenma.tvlauncher.SettingInvActivity" android:screenOrientation="landscape"/> <service android:enabled="true" android:exported="false" android:name="com.shenma.tvlauncher.view.MyServices"/> <service android:enabled="true" android:exported="false" android:name="com.shenma.tvlauncher.view.MyService"/> <service android:enabled="true" android:exported="false" android:name="com.shenma.tvlauncher.view.JSONService"/> <meta-data android:name="UMENG_APPKEY" android:value=""/> <meta-data android:name="UMENG_CHANNEL" android:value="smtv"/> <meta-data android:name="UMENG_KEY" android:value="1621e18154b078e16c"/> <meta-data android:name="TALKINGDATA_CHANNEL" android:value="king"/> <meta-data android:name="TALKINGDATA_VALUE" android:value="5465e78553b07de76f2b59"/>
07-25
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值