How does my IME know when the user clicks Send in the app?
I've written an IME but it doesn't receive any notification when the user clicks Send in the client app (e.g. SMS or Skype).开发者_C百科 This is annoying because if there is a typo in the last word it doesn't get corrected.
Thanks in advance,
Barry
There is currently no way to do this: the InputMethodService has no callback to allow the app to unambiguously declare I'm about to use the input text. Your best bet would be to setup a timer that continuously watches for changes corrects things (or indicates that a correction is available): I'm guessing you already have that.
Even with with platform IMEs sometimes incorrectly spelled text gets sent: if you think about a keyboard in general there is no standard way to communicate back to a keyboard that its time is done. You may be able to override requestHideSelf, onWindowHidden or onFinishInput to detect that the app has explicitly asked you to go away, but you won't be able to rely on those being used universally by all apps and the timing would be suspect in any case.
精彩评论