13

I see id == EditorInfo.IME_NULL used regularly in places which are supposed to match "Done" or "Enter" in addition to another condition such as the enter key or an IME action but I cannot find any explanation as to what exactly it is.

Monstieur
  • 7,992
  • 10
  • 51
  • 77
  • Please explain a bit more as in what you require. – Rahul Gupta Nov 25 '13 at 10:15
  • This code is preset everywhere when dealing with the "Enter" button on the soft keyboard. – Monstieur Nov 27 '13 at 09:23
  • This is basically used in key listeners. When you press any key on keyboard, you can check here if you require to do anything . For Eg :- If you press enter, you want to do something like to show a toast or something. For that you can put code here. Google it. You can find all the explanation there. – Rahul Gupta Nov 27 '13 at 09:38
  • Nothing explains what `IME_NULL` is. – Monstieur Sep 02 '14 at 05:22
  • @Locutus if my answer helped you, I would appreciate it if you could please review it and mark it as the answer.. thnx – angryITguy Sep 17 '15 at 04:26

2 Answers2

7

This code is preset everywhere when dealing with the "Enter" button on the soft keyboard.

The Andriod Documentation is not explicit, but IME_NULL is the generic key for "Enter"

This is also relevant in relation to IME's (Input Method Editor).

angryITguy
  • 9,332
  • 8
  • 54
  • 82
4

It's wrong, but it's been copied and pasted quite a bit and is probably more prevalent than code that actually uses the correct constant here.

Per the documentation, IME_NULL is supposed to represent the value of the imeOptions field when no option flags are set.

The correct constant in this case is IME_ACTION_UNSPECIFIED, which indicates that the user has instructed your app to take some action, but the exact action is not defined.

The two are interchangeable because they have the same integer value (zero).

j__m
  • 9,392
  • 1
  • 32
  • 56
  • This does explain the issue WRT why "IME_NULL" is *apparently* the event. They screwed the API up, or it was screwed up to start with. – CodeClown42 Jun 30 '22 at 16:34