KeirDavis
KeirDavis

Reputation: 665

Getting the text from programatically opening the android keyboard

I have opened the keyboard using this:

InputMethodManager mgr = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);

but I don't know how to get the text which has been inputted through the keyboard. Any help?

Upvotes: 2

Views: 172

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93569

The input method framework is based upon the idea of an input connection. The framework instantiates one between the keyboard and the EditText. If you want to accept text from the keyboard you need to implement that side of the interface yourself, then get the framework to use your interface as the other half of the input session. This is really, really non-trivial and if you do it wrong specialized keyboards like Swype, Swiftkey, etc will not work correctly. I wouldn't suggest doing it without a very good reason.

If you just want them to type into an existing edit text, focus that view instead. That way the input connection will be set to that view and everything will be done for you.

Upvotes: 1

Related Questions