Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when changing orientation #15

Open
dgenest65 opened this issue Aug 17, 2017 · 0 comments
Open

Problem when changing orientation #15

dgenest65 opened this issue Aug 17, 2017 · 0 comments

Comments

@dgenest65
Copy link

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);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant