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

Trt*_*Trt 5 android

我的清单中有这个:

<?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>
Run Code Online (Sandbox Code Playgroud)

现在问题就在这里:

 @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
         .............
         .................
          ............
    }
Run Code Online (Sandbox Code Playgroud)

当我将屏幕从纵向旋转到横向时,这被称为罚款。但是一旦我处于风景中,如果我转向另一个风景(即 180 度),它就不会射击。奇怪的是它只从portraittolandscapelandscapeto触发portrait

and*_*lic 1

从横向翻转到反向横向不是配置更改,因为它对于应用程序所在的环境是不可见的,因此系统不会发送事件。

您可以在此处找到更多信息和替代解决方案: https://groups.google.com/forum/# !topic/android-developers/IgBNQNgFUmk