没有调用Activity onConfigurationChanged()

时间:2014-11-21 11:23:21

标签: android android-manifest android-orientation

我的活动不是调用onConfigurationChanged()而是切换到横向。

我没有打电话setRequestedOrientation(int)

清单中已经更改,没有任何内容

<application
    android:allowBackup="true"
    android:configChanges="orientation|keyboardHidden"
    android:icon="@drawable/ic_launcher_application"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:uiOptions="none" >
    <activity
        android:name="application.controllers.LoginFrame"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:noHistory="true"
        android:windowSoftInputMode="stateHidden|adjustResize|adjustPan" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

这是我的活动代码:

public class LoginFrame extends AccountAuthenticatorActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_login_frame);

        // loginButton.setBackgroundColor(Color.TRANSPARENT);
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_INPUT_METHOD);

        System.out.println("RequestedOrientation Login = " + getRequestedOrientation());
        System.out.println("Orientation Login = " + getResources().getConfiguration().orientation);

    }

    @Override
    public void onBackPressed() {
        finish();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig){
        if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
            System.out.println("Turn");

        super.onConfigurationChanged(newConfig);
        Crashlytics.getInstance().log(Log.VERBOSE, "orientation.login", "" + newConfig.orientation);
        System.out.println("newConfig orientation = " + newConfig.orientation);
    }

    @Override
    protected void onSaveInstanceState(Bundle savedInstace){
        super.onSaveInstanceState(savedInstace);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstance){
        super.onRestoreInstanceState(savedInstance);
    }

    @Override
    public void onStart(){
        super.onStart();
    }

    @Override
    public void onResume(){
        super.onResume();
    }

    @Override
    public void onStop(){
        super.onStop();
    }

}

RES / styles.xml:

<!-- Application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat">

    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:animateFirstView">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">true</item>

    <!-- Pos HoneyComb device -->
    <item name="android:actionBarStyle">@style/theme.actionbar</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/theme.actionbar</item>
</style>

<style name="theme.actionbar" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="android:background">@color/application.actionbar.background</item>
</style>

修改

我不知道为什么收到的问题-1是不必要的这种行为。此外,因为它是一个非常彻底和难以找到的解决方案。

在寻找解决方案三天后,我发现this post帮助我解决了问题。擦除res / styles

中的行android:windowIsTranslucent就足够了

0 个答案:

没有答案