0

I am writing an accessibility service. I've been trying to focus EditText fields in a way that pops up the software keyboard and I have been unsuccessful. I am able to get the cursor into the EditText field, but the soft keyboard doesn't pop up. Given EditTextNode is an AccessibilityNodeInfo that I have gotten from various accessibility events and that said nodeInfo isEditable, isFocusable, isVisibleToUser and isClickable when I attempt all of these actions and they all return true upon completion.

editTextNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);

In my mind the above should simply work, and the fact that it does not is a bug in the Accessibility API, if not for my entire android version, at the very least on my device (Droid Ultra, Android 4.4.4). I have also tried:

editTextNode.performAction(AccessibilityNodeInfo.ACTION_FOCUS);

Puts focus into the field so I can see the input cursor, but no keyboard.

editTextNode.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);

Doesn't really do anything unless talkback is enabled.

editTextNode.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, someBundle);

Along with appropriate arguments this will work, but only if there is already text in the editText field. I need to pull the keyboard up on empty text fields as well. Yes, I tried inputing 0,0 for start and end text selection arguments. The SET_SELECTION method only works with text in the field!

This has been frustrating me for a couple days, hopefully you guys can help. Though I believe I've stumbled onto a bug and am going to have to wait for Android to update. Because the ACTION_CLICK method should really be all that is needed. But, I could be missing something silly, Accessibility API Doc is somewhat scant. Am willing to attempt anything.

MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • You are correct, this is a bug in the accessibility APIs. AccessibilityNodeInfo.ACTION_CLICK brings up the soft keyboard starting in Android 5.0 (v21) but did not work correctly in earlier versions. The only way to bring up the soft keyboard was for the user to double-tap, which would trigger the system to send a DOWN/UP touch event pair to the text field and bring up the soft keyboard. – alanv Oct 26 '14 at 09:13
  • So TL;DR there is no way to do this programatically from an accessibility service prior to API 21. – alanv Oct 26 '14 at 09:15

1 Answers1

0

To restate @alanv's comment in answer form:

You are correct, it is a bug in accessibility services prior to API 21.

JstnPwll
  • 8,585
  • 2
  • 33
  • 56