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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With