Skip to content

Instantly share code, notes, and snippets.

@mrvivacious
Last active November 21, 2020 11:00
Show Gist options
  • Select an option

  • Save mrvivacious/12d07fbf2c84bf858f06746d445dbb2c to your computer and use it in GitHub Desktop.

Select an option

Save mrvivacious/12d07fbf2c84bf858f06746d445dbb2c to your computer and use it in GitHub Desktop.
Paste text in an accessibility node on Android
// For Android
// Class must extend AccessibilityService to use this function verbatim
// Have fun
// Function will overwrite any existing text in the node
public void setText(AccessibilityNodeInfo node, String textToSet) {
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
textToSet);
node.performAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_TEXT.getId(), arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment