API原文说明:
android:configChanges
Lists configuration changes that the activity will handle itself. When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.

Any or all of the following strings are valid values for this attribute. Multiple values are separated by '|' — for example, "locale|navigation|orientation".

All of these configuration changes can impact the resource values seen by the application. Therefore, when onConfigurationChanged() is called, it will generally be necessary to again retrieve all resources (including view layouts, drawables, and so on) to correctly handle the change.

在一些特殊的情况中,你可能希望当一种或者多种配置改变时避免重新启动你的activity。你可以通过在manifest中设置android:configChanges属性来实现这点。
你可以在这里声明activity可以处理的任何配置改变,当这些配置改变时不会重新启动activity,而会调用activity的
onConfigurationChanged(Resources.Configuration)方法。如果改变的配置中包含了你所无法处理的配置(在android:configChanges并未声明),
你的activity仍然要被重新启动,而onConfigurationChanged(Resources.Configuration)将不会被调用。

其次:android:configChanges=""中可以用的值:keyboard|mcc|mnc|locale|touchscreen|keyboardHidden|navigation|orientation……
Configuration 类中包含了很多种信息,例如系统字体大小,orientation,输入设备类型等等.(如上图)
比如:android:configChanges="orientation|keyboard|keyboardHidden"

当Configuration改变后,ActivityManagerService将会发送"配置改变"的广播,会要求ActivityThread 重新启动当前focus的Activity.
这是默认情况,我们不做任何处理,如果我们android:configChanges来配置Activity信息,那么就可以避免对Activity销毁再重新创建,而是调用
onConfigurationChanged方法。

通过查阅Android API可以得知android:onConfigurationChanged实际对应的是Activity里的onConfigurationChanged()方法。
在AndroidManifest.xml中添加上诉代码的含义是表示在改变屏幕方向、弹出软件盘和隐藏软键盘时,不再去执行onCreate()方法,
而是直接执行onConfigurationChanged()。如果不申明此段代码,按照Activity的生命周期,都会去执行一次onCreate()方法,而onCreate()方法通常会在显示之前做一些初始化工作。所以如果改变屏幕方向这样的操作都去执行onCreate()方法,就有可能造成重复的初始化,降低程序效率是必然的了,而且更有可能因为重复的初始化而导致数据的丢失。这是需要千万避免的。

参考:
Android学习笔记——关于onConfigurationChanged
http://www.cnblogs.com/wisekingokok/archive/2011/10/06/2199948.html

http://www.cnblogs.com/bluestorm/p/3622444.html

onConfigurationChanged信息处理 监听屏幕旋转 语言变换 键盘滑动 
http://fghzhaopai.blog.163.com/blog/static/4780555620116882211560/

转:onConfigurationChanged的作用的更多相关文章

  1. Android onConfigurationChanged的作用

    API原文说明: android:configChangesLists configuration changes that the activity will handle itself. When ...

  2. [Android Pro] AsyncTaskLoader vs AsyncTask

    reference to : http://blog.csdn.net/a910626/article/details/45599133 我看了一下asyncTask是从LV3开始,AsyncTask ...

  3. onWindowFocusChanged重要作用 and Activity生命周期

    onWindowFocusChanged重要作用 Activity生命周期中,onStart, onResume, onCreate都不是真正visible的时间点,真正的visible时间点是onW ...

  4. if __name__== "__main__" 的意思(作用)python代码复用

    if __name__== "__main__" 的意思(作用)python代码复用 转自:大步's Blog  http://www.dabu.info/if-__-name__ ...

  5. (转载)linux下各个文件夹的作用

    linux下的文件结构,看看每个文件夹都是干吗用的/bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管理和配置文件 /etc/rc.d 启动的配置文件和脚本 /home 用户主目录的基 ...

  6. github中的watch、star、fork的作用

    [转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...

  7. web.xml中welcome-file-list的作用

    今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...

  8. web.xml中load-on-startup的作用

    如下一段配置,熟悉DWR的再熟悉不过了:<servlet>   <servlet-name>dwr-invoker</servlet-name>   <ser ...

  9. SQLSERVER中NULL位图的作用

    SQLSERVER中NULL位图的作用 首先感谢宋沄剑提供的文章和sqlskill网站:www.sqlskills.com,看下面文章之前请先看一下下面两篇文章 SQL Server误区30日谈-Da ...

随机推荐

  1. python2.7_1.3_获取远程设备的IP地址

    代码如下: # -*- coding: utf-8 -*- import socket def get_remote_machine_info(): remote_host = 'www.python ...

  2. sortable.js 华丽丽的排序

    首先导入这几个资源 <link href="/css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type ...

  3. Tomcat中配置自定义404错误页面

    404,50x这种错误经常遇到. 如果%CATALINA_HOME%\conf\web.xml和具体应用中都有设置%CATALINA_HOME%\webapps\ROOT\WEB-INF\web.xm ...

  4. "No appenders found for logger" and "Please configure log4j properly"

    Why do I see a warning about "No appenders found for logger" and "Please configure lo ...

  5. notify()、notifyAll()和wait()

    看到一道面试题,写一个多线程程序,交替输出1.2.1.2…… 先写下程序: /** * Created by Andrew on 2015/10/28. */ public class OutputT ...

  6. 数据结构——链表(linkedlist)

    基本分类: 1.单向链表 2.带尾指针的单向链表 3.双向循环链表 以下分类进行说明 1.单向链表 基本元素:*front //头节点 *next //下一节点 声明:node<T>*p; ...

  7. 【转】 随机梯度下降(Stochastic gradient descent)和 批量梯度下降(Batch gradient descent )的公式对比、实现对比

    梯度下降(GD)是最小化风险函数.损失函数的一种常用方法,随机梯度下降和批量梯度下降是两种迭代求解思路,下面从公式和实现的角度对两者进行分析,如有哪个方面写的不对,希望网友纠正. 下面的h(x)是要拟 ...

  8. uva - The Lottery(容斥,好题)

    10325 - The Lottery The Sports Association of Bangladesh is in great problem with their latest lotte ...

  9. PDO--PHP Data Objects

    PDO的环境配置:开启支持PDO 在php.ini配置文件里开启: extension=php_pdo.dll extension=php_pdo_mysql.dll 在PDO操作中涉及到类:PDO. ...

  10. 饭卡------HDOJ杭电2546(还是01背包!!!!!!)

    Problem Description 电子科大本部食堂的饭卡有一种非常诡异的设计,即在购买之前推断剩余金额. 假设购买一个商品之前,卡上的剩余金额大于或等于5元,就一定能够购买成功(即使购买后卡上剩 ...