通过设置这个属性可以使Activity捕捉设备状态变化,以下是可以被识别的内容:
CONFIG_FONT_SCALE
CONFIG_MCC
CONFIG_MNC
CONFIG_LOCALE
CONFIG_TOUCHSCREEN
CONFIG_KEYBOARD
CONFIG_KEYBOARDHIDDEN
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.全局字体大小缩放发生改变
通过一个例子介绍这个属性的用法: 首先需要修改项目的manifest:
View Code XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidres.ConfigChangedTesting"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ConfigChangedTesting"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
在Activity中添加了 android:configChanges属性,目的是当所指定属性(Configuration Changes)发生改变时,通知程序调用 onConfigurationChanged()函数。
分享到:
相关推荐
关于Activity生命周期...2.configChanges属性解析 3.orientation属性 4.keyboardHidden属性 5.screenSize属性 6.总结 activity生命周期方法 默认情况下,activity从创建到销毁会执行以下生命周期方法 onCreate –>onSt
ActivityAttacher就是附着在上面4个模板Activity里的Activity代理ActivityAttacher中持有一个Activity实例对象,是在onCreate时赋值的ActivityAttacher可以处理Activity中的所有配置和生命周期ActivityAttacher提供...
方法一: 通过Theme.Translucent ...只需要在Manifest中需要透明的Activity内设置theme为以上任意一个就可以了 <activity android:name=com.vixtel.simulate.MainApp android:configChanges=keyboardHidden|
1. 在AndroidManifest.xml中为Activity设置configChanges属性, application android:icon=@drawable/icon android:label=@string/app_name> <activity android:name=.MainActivity android:label=@string/app_...
在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden 例如: <activity android:name=".Main" android:label="@string/app_name" android:...
android:configChanges="orientation|keyboardHidden"的使用-附件资源
(2) 三星的camera强制切换到横屏 导致Activity重启生命周期 (但是部分机型 配置 android:configChanges 也不能阻止横竖屏切换); 我的解决方法为 如果 activity 的销毁如果无法避免 那么在activity销毁之前调用 ...
为了避免activity 重新加载过程中有闪屏的现象,则需要再清单文件中配置该activity 的属性 android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation|screenSize",详细信息请参阅...
首先在Mainifest.xml的Activity元素中加入android:configChanges=”orientation|keyboardHidden”属性 <activityandroid name=.FileBrowserandroid:label app_nameandroid:configChanges=orientation|...
android:name="android.permission.READ_EXTERNAL_STORAGE"/>注意,如果横竖屏切换不想重新走一遍生命周期,还需要在表单中设置Activity的configChanges属性:<activity android:name=".PlayActivity" ...
这个是Android 4高级编程第三版的完整pdf文档,受最大上传大小的限制,切分成了十份,每份就最好的数字不一样,比如说第二份就是Android 4 高级编程第三版_2,代码可以在清华出版社的网站上下载
这种情况适用于屏幕旋转和配置变化,只要作用是阻止Activity重建,因此对于【语言】【时区】的调整可能需要重新启动Activity才能更新。 注意: 语言的变化需要配置为 android:configChanges=locale|layoutDirection...
部分网友会发现Activity在切换到后台或布局从横屏LANDSCAPE切换到PORTRAIT,会重新切换Activity会触发一次onCreate方法,我们可以在androidmanifest.xml中的activit元素加入这个属性Android:configChanges=”...
在您的AndroidManifest文件查找中包含相应的活动标签,并将android:configChanges="orientation|screenSize"到其中。 现在您的活动标签将类似于<activity name= ".YourActivity" android:configChanges=...
FragmentDemo
偶然在项目中用到播放视频时,需要横屏将视频全屏播放,...声明Activity需要捕捉的事件类型,在manifest的配置: <activity android:name=.MainActivity android:configChanges=orientation|keyboard|layoutDirect
解决方法:在manifest文件里面给activity加上下面一行属性 android:configChanges=screenSize|smallestScreenSize|screenLayout|orientation 2.当启用多窗口模式时,可能有改变原UI的需求,这时可以在代码里面修改...
在 AnroidMainifest.xml 的 activity 元素中加入: 代码如下:android:configChanges=”orientation|keyboardHidden”或 代码如下:android:configChanges=”orientation|keyboard|keyboardHidden” 表示在改变屏幕...
guolin的fragmentdemo, 修改了切屏时重叠问题, AndroidManifest <activity加入 android:configChanges="keyboardHidden|orientation|screenSize" 即可