2

I'm trying to manage the Next event on the Google Keyboard on a Google Nexus 5. I want my application to check user information when the Next button gets pressed.

The code looks like this:

 private TextView.OnEditorActionListener GenerateEditorListeners()
{
    return new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if(actionId == EditorInfo.IME_NULL  && event.getKeyCode() == KeyEvent.KEYCODE_ENTER){

                if (!finished)
                {
                    if (CheckUserInfo()) finished = true;
                }
                return true;
            }
            else
            {
                return false;
            }
        }
    };
}

On a Samsung Galaxy S4 works perfect, but on a Google Nexus 5 the actionId = 0 and the event = null. So I figure out that the Samsung keyboard works fine with this code, but doesn't happen the same with the Google Keyboard.

Any idea on why it's not wokring for Google's keyboards?

EDIT: I've read in this post that Google keyboard has a bug in some LatinIME keyboards.... I'm using a latin one. If that's the problem, how to solve it?

Community
  • 1
  • 1
Sonhja
  • 8,230
  • 20
  • 73
  • 131

1 Answers1

0

I could solve it by using the OnKeyListener event:

 textUserEmail.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if(event.getKeyCode() == KeyEvent.KEYCODE_ENTER){

                if (!finished)
                {
                    if (CheckUserInfo()) finished = true;
                }
                return true;
            }
            else
            {
                return false;
            }
        }
    });

Now it works in all keyboards.

Sonhja
  • 8,230
  • 20
  • 73
  • 131