Keyboard dismissed on rotation to landscape mode Android - android

Running into a strange problem.
When I'm on portrait and have the keyboard visible and rotate to landscape, the keyboard is dismissed (with or without text in the EditText). The text is also retained on rotation.
When I'm on landscape and have the keyboard visible and rotate to portrait, the keyboard continues to be visible on portrait.
Any idea what could be going wrong? I'm not handling configChanges myself and I don't intend to.
I also tried using stateUnchanged | adjustResize in the XML and that did not change anything.

Related

Android Keyboard fix orientation

I have a Android Keyboard like a SoftKeyboard and I want to fix the screen in portrait orientation when the keyboard is activated, so, use the keyboard with the editTExt of the app just in portrait (I have just the keyboard, no the app).

Android detect keyboard hide in landscape mode

Using the method shown in this thread - How to check visibility of software keyboard in Android?
I am able to detect keyboard hide when in portrait mode or in landscape mode where the keyboard is not in fullscreen. If keyboard in landscape mode is fullscreen then, the layout changes are not triggered and hence i cannot detect it in the OnGlobalLayoutListener !
Please help me with this? Is there no simple way to detect keyboard hide?
NOTE: I cannot afford to change anything in the manifest file. It should all be done through code dynamically!
Thanks!

Retain soft-input/IME state on Orientation change

I'm having a small user experience issue in my app;
When changing from landscape to portrait (or portrait to landscape) with the Soft Keyboard open, the keyboard hides.
What I want to do is to stop the keyboard hiding on orientation change.
(Edit - I don't want to force the keyboard open, if the keyboard was hidden before the orientation change, I want it to stay hidden - I want to retain the keyboards open/closed state).
I've looked around for an answer and it seems adding stateUnchanged to the windowSoftInputMode options in the manifest for the Activity is the correct way to solve this (as described in the android documentation:
android:windowSoftInputMode="stateUnchanged|adjustResize"
The problem is this seems to have absolutely no effect.
Does anybody know of any caveats to this functionality? Does it perhaps not work if the EditText which is focused is in a Fragment?
Add this to your code and it will work :
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

keyboard disappears while orientation change to landscape mode

I am enabling orientation change in focusChangeListener of an edittext in my app.
It is working fine, but the issue is if the user flips the keyboard to landscape mode keyboard disappears.
It will come up only if user tap on edittext again or change orientation to portrait mode.
I need to display keyboard in landscape mode without touching the edittext.
Please help me.
Generally, its a bad idea to mess with the default IME behavior because there are devices out there with hardware keyboards.
Now, that you have been warned, listen for the orientation change and if the keyboard was visible before the change and there is no hardware keyboard on the device, show the keyboard manually.
Try using android:configChanges="orientation" into your manifest class.
<activity
android:name=".classname"
android:configChanges="keyboardHidden|orientation"
>
if works then accept it.

How can I specify ime options for soft keyboard when not using editview?

In my application, I am showing/hiding the keyboard to allow the user to manipulate a custom widget. There is no EditText that has focus.
The problem I am having is that I want the layout to adjust in size when the keyboard shows. This is normally done by adding android:windowSoftInputMode="adjustResize" to the activity tag in the manifest. This does work when the device (currently the 7in Galaxy Tab running 2.2) is in portrait mode but when rotated to landscape, the layout does not adjust size and the keyboard hides half the screen.
Now, I noticed that if instead I use an EditView that has android:imeOptions="flagNoExtractUi", the layout resizes appropriately. Is there any way to achieve the same effect on a keyboard displayed through a window token?
Adding a hidden EditView to the screen is not ideal since it will change the implementation rather drastically.
For reference, here is the code I use to show the keyboard within the custom widget.
mInputMethod = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethod.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
requestFocus();
setOnKeyListener(this);
and to hide.
mInputMethod.hideSoftInputFromWindow(getWindowToken(), 0);
setOnKeyListener(null);

Categories

Resources