I'm developing an Android Accessibility Service. I got an AccessibilityNodeInfo that represents an EditText. Is possibile to edit the contained text?
I tried with mynode.setText("aaa")
but i get IllegalStateException
as described in official documentation http://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html
Any ideas?
Thanks
You can use ACTION_SET_TEXT for >= android 21.
Here is the example of it:
AccessibilityNodeInfo source = event.getSource();
if (source != null & event.getClassName().equals("android.widget.EditText")) {
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo
.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, "android");
source.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
}