简体   繁体   English

Android - 切换到相同方向时调用“onConfigurationChanged()”(即横向反转横向)

[英]Android - “onConfigurationChanged()” not called when switching to same orientation (i.e landscape to reverse landscape))

I have this in my manifest: 我的清单中有这个:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.apps.foo.bar" >

    <uses-feature android:name="android.hardware.camera" />
    <uses-permission android:name="android.permission.CAMERA" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainPreviewActivity"
            android:label="@string/app_name"
            android:screenOrientation="fullSensor"
            android:configChanges="orientation|screenSize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Now the problem is here: 现在的问题是:

 @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
         .............
         .................
          ............
    }

This is being called fine when I rotate the screen from portrait to landscape. 当我将屏幕从纵向旋转到横向时,这被称为正常。 But once I am in landscape, if I turn to the other landscape (ie 180 degrees) it is not firing. 但是一旦我在风景中,如果我转向另一个风景(即180度),它就不会发射。 The strange thing is that it fires only from portrait to landscape and landscape to portrait . 奇怪的是,它只从portraitlandscape ,从landscapeportrait才会发射。

Flipping from landscape to reverse landscape is not a configuration change as it is invisible to the environment the app is in and hence the system does not send an event. 从横向翻转到反向横向不是配置更改,因为它对应用程序所处的环境是不可见的,因此系统不会发送事件。

You can find more information and alternate solutions here: https://groups.google.com/forum/#!topic/android-developers/IgBNQNgFUmk 您可以在此处找到更多信息和备用解决方案: https//groups.google.com/forum/#!topic / installer -developers /IgBNQNgFUmk

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - 检测反向横向方向 - Android - detect reverse landscape orientation 横向app和onConfigurationChanged从未调用过 - Landscape app and onConfigurationChanged never called 更改方向时,onConfigurationChanged()调用两次Landscape to Portrait - onConfigurationChanged() calling twice when change orientation Landscape to Portrait 如何在 Android 中防止反向横向但允许横向? - How to prevent reverse-landscape orientation but allow landscape orientation in Android? 以REVERSE_PORTRAIT和REVERSE_LANDSCAPE模式启动模拟器,即UPSIDE-DOWN模式 - Launch emulator in REVERSE_PORTRAIT and REVERSE_LANDSCAPE mode i.e UPSIDE-DOWN mode 在android中显示反向横向时如何锁定屏幕方向? - How to Lock screen orientation when displaying reverse landscape in android? 切换到横向方向很慢 - Switching to landscape orientation is slow 当我开始在风景中活动时调用onConfigurationChanged,该窗口大约在1秒后显示 - onConfigurationChanged called when i start activity in landscape,the window show about 1s later 当我将方向肖像更改为横向时,我希望布局应针对横向进行更改,并且视频是从android中的相同位置开始的? - when i changed orientation portrait to landscape i want layout should change for landscape and video is start from same position in android? 如何在Android 2.3.3中使用onConfigurationChanged()和newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE - How to use onConfigurationChanged() and newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE in android 2.3.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM