zoukankan      html  css  js  c++  java
  • onConfigurationChanged未被调用的原因

    今天碰到一个奇怪的问题。

    onConfigurationChanged未被调用。

    根据正常认知,在AndroidManifest.xml中设置android:configChanges="orientation“,

    然后在Java代码中重写onConfigurationChanged,即不会重复Activity生命周期,而是调用onConfigurationChanged。

    然而今天这种做法没有效果,什么原因呢。

    原来,自从Android 3.2(API 13),screen size也开始跟着设备的横竖切换而改变。

    所以,在AndroidManifest.xml里设置的MiniSdkVersion和 TargetSdkVersion属性大于等于13的情况下,

    如果你想阻止程序在运行时重新加载Activity,除了设置”orientation“,你还必须设置"ScreenSize"。

    解决方法:

    AndroidManifest.xml中设置android:configChanges="orientation|screenSize

    4.2又碰到同样的问题了,还得再加上个"layoutDirection"

  • 相关阅读:
    python搭建开发环境
    django初探
    linux下安装Composer
    文件记录追加 file_put_content
    自定义导出表格
    异步处理接口 fsockopen
    appcache checking update
    js pix
    Event Aggregator
    ko list and css gradient
  • 原文地址:https://www.cnblogs.com/jayceli/p/2718984.html
Copyright © 2011-2022 走看看