Set text in AccessibilityNodeInfo

后端 未结 1 1206
执念已碎
执念已碎 2020-12-29 10:47

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 <

相关标签:
1条回答
  • 2020-12-29 11:35

    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);
    }
    
    0 讨论(0)
提交回复
热议问题