在一个Activity中可以指定参数android:在一个Activity中可以指定参数android:ConfigChanges,用于捕获手机状态的改变。在Activity中添加了android:configChanges属性,目的是当所指定属性(Configuration Changes)发生改变时,通知程序调用onConfigurationChanged()函数。
以下是可以被识别的内容:
CONFIG_FONT_SCALE
CONFIG_MCC
CONFIG_MNC
CONFIG_LOCALE
CONFIG_TOUCHSCREEN
CONFIG_KEYBOARD
CONFIG_NAVIGATION
CONFIG_ORIENTATION
设置方法:将下列字段用“|”符号分隔开,例如:“locale|navigation|orientation
”
Value
|
Description
|
“mcc“
|
The IMSI mobile country code (MCC) has changed — that is, a SIM hasbeen detected and updated the MCC.移动国家号码,由三位数字组成,每个国家都有自己独立的MCC,可以识别手机用户所属国家。
|
“mnc“
|
The IMSI mobile network code (MNC) has changed — that is, a SIM hasbeen detected and updated the MNC.移动网号,在一个国家或者地区中,用于区分手机用户的服务商。
|
“locale“
|
The locale has changed — for example, the user has selected a new language that text should be displayed in.用户所在地区发生变化。
|
“touchscreen“
|
The touchscreen has changed. (This should never normally happen.)
|
“keyboard“
|
The keyboard type has changed — for example, the user has plugged in an external keyboard.键盘模式发生变化,例如:用户接入外部键盘输入。
|
“keyboardHidden“
|
The keyboard accessibility has changed — for example, the user has slid the keyboard out to expose it.用户打开手机硬件键盘
|
“navigation“
|
The navigation type has changed. (This should never normally happen.)
|
“orientation“
|
The screen orientation has changed — that is, the user has rotated the device.设备旋转,横向显示和竖向显示模式切换。
|
“fontScale“
|
The font scaling factor has changed — that is, the user has selected a new global font size.全局字体大小缩放发生改变
|
但是显然,大部分应用不会去覆盖onConfigurationChanged方法,太累!但是我们还是必须有android:ConfigChanges,因为有些手机不配置这一项的话,在状态发生改变的时候,居然会报错……,用于捕获手机状态的改变。在Activity中添加了android:configChanges属性,目的是当所指定属性(Configuration Changes)发生改变时,通知程序调用onConfigurationChanged()函数。
以下是可以被识别的内容:
CONFIG_FONT_SCALE
CONFIG_MCC
CONFIG_MNC
CONFIG_LOCALE
CONFIG_TOUCHSCREEN
CONFIG_KEYBOARD
CONFIG_NAVIGATION
CONFIG_ORIENTATION
设置方法:将下列字段用“|”符号分隔开,例如:“locale|navigation|orientation
”
Value
|
Description
|
“mcc“
|
The IMSI mobile country code (MCC) has changed — that is, a SIM hasbeen detected and updated the MCC.移动国家号码,由三位数字组成,每个国家都有自己独立的MCC,可以识别手机用户所属国家。
|
“mnc“
|
The IMSI mobile network code (MNC) has changed — that is, a SIM hasbeen detected and updated the MNC.移动网号,在一个国家或者地区中,用于区分手机用户的服务商。
|
“locale“
|
The locale has changed — for example, the user has selected a new language that text should be displayed in.用户所在地区发生变化。
|
“touchscreen“
|
The touchscreen has changed. (This should never normally happen.)
|
“keyboard“
|
The keyboard type has changed — for example, the user has plugged in an external keyboard.键盘模式发生变化,例如:用户接入外部键盘输入。
|
“keyboardHidden“
|
The keyboard accessibility has changed — for example, the user has slid the keyboard out to expose it.用户打开手机硬件键盘
|
“navigation“
|
The navigation type has changed. (This should never normally happen.)
|
“orientation“
|
The screen orientation has changed — that is, the user has rotated the device.设备旋转,横向显示和竖向显示模式切换。
|
“fontScale“
|
The font scaling factor has changed — that is, the user has selected a new global font size.全局字体大小缩放发生改变
|
但是显然,大部分应用不会去覆盖onConfigurationChanged方法,太累!但是我们还是必须有android:ConfigChanges,因为有些手机不配置这一项的话,在状态发生改变的时候,居然会报错……
摘自:http://blog.csdn.net/coding_or_coded/article/details/6889870
分享到:
相关推荐
亲测可用 当前页面 和子页面 都是可以的 配置简单方便 大家可用下载备用
android:configChanges="orientation|keyboardHidden"的使用-附件资源
android:configChanges="orientation|keyboardHidden"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> ...
android4.0 禁止横竖屏切换使:android:configChanges="orientation|keyboardHidden|screenSize" 感兴趣的朋友可以了解下哈
(2) 三星的camera强制切换到横屏 导致Activity重启生命周期 (但是部分机型 配置 android:configChanges 也不能阻止横竖屏切换); 我的解决方法为 如果 activity 的销毁如果无法避免 那么在activity销毁之前调用 ...
方法一: 通过Theme.Translucent @android:style/Theme.Translucent @android:style/Theme.Translucent.NoTitleBar @android:style/Theme.Translucent.NoTitleBar.... android:configChanges=keyboardHidden|
android activity 执行屏幕横竖屏切换... android:configChanges="keyboardHidden|orientation|screenSize",详细信息请参阅附件源码,技术交流 杨兴达 电话:18010180585 邮箱;yangxingda1988@163.com LOG过滤: yxd
在 AnroidMainifest.xml 的 activity 元素中加入: 代码如下:android:configChanges=”orientation|keyboardHidden”或 代码如下:android:configChanges=”orientation|keyboard|keyboardHidden” 表示在改变屏幕...
android:name="android.permission.READ_EXTERNAL_STORAGE"/>注意,如果横竖屏切换不想重新走一遍生命周期,还需要在表单中设置Activity的configChanges属性: android:name=".PlayActivity" android:...
Android微信6.6.7版...<activity android:configChanges="keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:label="@string/btr" android:launchMode="singleTop" android:name=...
这个是Android 4高级编程第三版的完整pdf文档,受最大上传大小的限制,切分成了十份,每份就最好的数字不一样,比如说第二份就是Android 4 高级编程第三版_2,代码可以在清华出版社的网站上下载
②android:configChanges+onConfigurationChanged 这种情况适用于屏幕旋转和配置变化,只要作用是阻止Activity重建,因此对于【语言】【时区】的调整可能需要重新启动Activity才能更新。 注意: 语言的变化需要配置...
当您在Activity上使用android:configChanges标志时,您将无法在纵向和横向使用不同的布局 configChanges-不带标志 没有android:configChanges标志,您将能够在纵向和横向使用不同的布局 screenOrientation-带有...
android:configChanges=screenSize|smallestScreenSize|screenLayout|orientation 2.当启用多窗口模式时,可能有改变原UI的需求,这时可以在代码里面修改: @Override public void onMultiWindowModeChan
react-native-android-fullscreen-webview 概述 默认情况下,React Native随附的WebView组件无法显示... android:configChanges="orientation" android:hardwareAccelerated="true" 例子: <activity android:nam
guolin的fragmentdemo, 修改了切屏时重叠问题, AndroidManifest 加入 android:configChanges="keyboardHidden|orientation|screenSize" 即可
从事Android开发,免不了会在应用里嵌入一些广告SDK,在嵌入了众多SDK后,发现几乎每个要求在AndroidManifest.xml申明Activity的广告SDK都会要求加上注明这么一句属性: 代码如下:android:configChanges=”...
NiceVieoPlayer 产品特点 用IjkPlayer / MediaPlayer + TextureView封装,可以切换IjkPlayer,MediaPlayer。 支持本地和网络视频播放。... android:configChanges="orientation|keyboardHidden|scre