`
lansezhixing123
  • 浏览: 5797 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

android ConfigChanges

阅读更多

 

在一个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国际化中英文切换demo

    `android:configChanges="locale"`表示当语言更改时,应用会重新加载配置,以便更新资源。 在运行时,用户可以通过系统设置进行语言切换。然而,如果你希望在应用内提供切换语言的功能,可以编写一个方法来动态改变...

    android:configChanges="orientation|keyboardHidden"的使用-附件资源

    android:configChanges="orientation|keyboardHidden"的使用-附件资源

    Android 销毁当前的Activity

    让 Android 横竖屏切换时不销毁当前的 Activity 需要使用 `android:configChanges` 属性和 `onConfigurationChanged` 方法。同时,我们也需要正确处理屏幕方向的改变,以确保应用程序的正确运行。

    Android应用源码之(横竖屏切换处理-IT计算机-毕业设计.zip

    2. **自定义处理**:设置`android:configChanges="orientation"`或`android:configChanges="screenOrientation"`,当屏幕方向改变时,系统会调用`onConfigurationChanged(Configuration newConfig)`方法,让你在不...

    android edittext不弹出软键盘三种方法

    android:configChanges="orientation|keyboardHidden"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> ...

    Android如何禁止横屏竖屏的变换

    总的来说,通过在AndroidManifest.xml中正确设置`android:configChanges`属性,并在Activity中忽略配置变化,可以在Android 4.0及以上版本中实现禁止横屏竖屏切换的功能。然而,这种方法可能会导致用户界面在不同...

    Android代码-MyRotation.zip

    总之,Android开发者需要了解如何适配屏幕旋转,包括使用`android:configChanges`、`onConfigurationChanged()`以及通过`ActivityInfo.SCREEN_ORIENTATION_*`常量来设定屏幕方向。"MyRotation.zip"的源代码应该能...

    Android9.0悬浮按钮一键分屏SplitScreen.zip

    通过设置`android:configChanges`和`android:supportsPictureInPicture`属性,表明Activity支持分屏模式。 总结,通过分析`Android9.0悬浮按钮一键分屏SplitScreen.zip`的内容,我们可以了解到如何在Android 9.0上...

    Android webview调用摄像头扫描二维码

    android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"> <action android:name="android....

    Android笔记之:onConfigurationChanged详解

    然而,通过在 `AndroidManifest.xml` 文件中为相应 `Activity` 设置 `android:configChanges` 属性,我们可以控制配置变化时的行为。 例如,如果我们在 `AndroidManifest.xml` 中写入: ```xml android:name="....

    ZXing Android二维码/条码扫描,2020Android Studio版本,横竖屏都支持

    将`android:configChanges`设置为`orientation|screenSize`,然后在活动中处理配置改变事件,可以确保扫描界面在横竖屏切换时正确显示。同时,需要注意保存和恢复活动的状态,防止屏幕旋转时数据丢失。 在实际开发...

    Android横竖屏贴换调动方法

    本篇文章将深入解析Android横竖屏切换时Activity生命周期的变动,以及如何通过配置`android:configChanges`属性来控制Activity的行为。 首先,当我们不进行任何特殊配置时,即在`AndroidManifest.xml`中没有指定`...

    Android常用技巧.docx

    其次,关于重新载入问题,当屏幕方向改变时,如果不希望重新加载`Activity`,可以利用`AndroidManifest.xml`中的`android:configChanges`属性。将该属性设置为`orientation`,如: ```xml android:name=".Your...

    Android相机 解决三星bug版本

    (2) 三星的camera强制切换到横屏 导致Activity重启生命周期 (但是部分机型 配置 android:configChanges 也不能阻止横竖屏切换); 我的解决方法为 如果 activity 的销毁如果无法避免 那么在activity销毁之前调用 ...

    Fragment的使用,隐藏显示以及androidPad横竖屏切换

    为了避免这种情况,可以在AndroidManifest.xml中为相应Activity设置`android:configChanges="orientation|screenSize"`,然后在Activity中覆盖onConfigurationChanged()方法,处理横竖屏切换。 ```xml android:...

    Android开发,高德地图应用内置导航,无需跳出APP的导航

    android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"/> android:name="com.autonavi.minimap.AutoNaviMapActivity" android:configChanges="orientation|...

    Android集成支付宝SDK实现支付功能

    android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:exported="false" android:windowSoftInputMode="adjustResize" /> android:name="com.alipay.sdk.auth.AuthActivity" ...

    shareSDK android 版本在cocos2d-x-2.2.6的集成

    android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask" android:theme="@android:style/Theme.Translucent.NoTitleBar" /> android:name=...

    Android横竖屏切换处理Demo源码.rar

    例如,设置`android:configChanges="orientation|screenSize"`可以使Activity不被销毁,而是直接调用`onConfigurationChanged()`方法。 3. **资源文件夹命名**: Android支持根据不同的屏幕方向创建不同的布局资源...

Global site tag (gtag.js) - Google Analytics