Set text to AccessibilityNodeInfo

I am developing an Android accessibility service. I got an AccessibilityNodeInfo that represents an EditText. Can I edit the edited text?

I tried with mynode.setText("aaa") , but I got an IllegalStateException as described in the official documentation http://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html

Any ideas? Thanks

+7
source share
1 answer

You can use ACTION_SET_TEXT for> = android 21. Here is an example of this:

 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); } 
+12
source

All Articles