2

I am working on an app which is in landscape mode.

When I open default keyboard programmatically it does not consume any input events in landscape mode (opens keyboard but does not show any preview of keyboard click). But if I open default keyboard in portrait it opens keyboard & shows the preview of a key on which I click i.e it works as expected in portrait mode.

I don't know why it is not accepting inputs in landscape mode.

Here is how I am opening the keyboard.

final InputMethodManager inputMethodManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

Also, if I specify flags called InputMethodManager.SHOW_IMPLICIT it does not even show the keyboard.

Kaustubh
  • 653
  • 6
  • 21

2 Answers2

0

Read this:

How to show soft-keyboard when edittext is focused

EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);

And remember to put

<activity
[...]
android:windowSoftInputMode="adjustPan"
[...]
>

in your manifest

Community
  • 1
  • 1
Alessandro Verona
  • 1,157
  • 9
  • 23
0

I had exact the same issue in combination with a custom View.

To fix this problem I needed to implement onCreateInputConnection in the custom view to set the InputType to TYPE_CLASS_TEXT.

If you need to capture onKeyDown and onKeyUp events for the backspace key you can use TYPE_TEXT_VARIATION_NORMAL.

Here an example:

/**
 * needed make softkeyboard work in landscape mode and to capture backspace.
 */
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs){
    outAttrs.inputType = InputType.TYPE_TEXT_VARIATION_NORMAL;
    outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_FULLSCREEN;
    return null;
}
giri
  • 26
  • 5