Skip to content

Problem when changing orientation #15

@dgenest65

Description

@dgenest65

This problem happen when activity attribut: android:configChanges="orientation" is used in the manifest.
With this attribute set, the activity is not destroyed/recreated when we change orientation.
That mean that KeyboardWatcher is not destroyed/recreated neither.
So the initialValue is now wrong and since the detection of the presence of the keyboard is base on that, onKeyboardClosed() and onKeyboardShown() are thrown wrongly.
So it would be nice to add support for that use case, for example add a resetInitialValue method or something like that.

For now the solution I found is to destroy/recreate the KeyboardWatcher in the onConfigurationChanged method:

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

    if (mKeyboardWatcher != null) {
        mKeyboardWatcher.destroy();
        mKeyboardWatcher = new KeyboardWatcher(this);
        mKeyboardWatcher.setListener(this);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions