I am using an accessibility service to monitor the window for EditText
fields. I then need to set the value of these EditText
fields. See the following code:
Meta data:
<?xml version="1.0" encoding="utf-8" ?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackSpoken"
android:accessibilityFlags="flagDefault"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:canRequestEnhancedWebAccessibility="true"/>
In onAccessibilityEvent
of the service:
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, "some value");
source.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
}
This works properly when viewing another app.
When viewing a website in the android browser I see see that it properly finds the EditText
(gets all the way to my performAction
code), however, calling the SET_TEXT
action on performAction
does nothing.
How do I set the text value of a website input
field (accessibility service finds it as an EditText
)? Do I need to use EnhancedWebAccessibility
in some way to inject Javascript? If so, how do I do that? I cannot find any documentation on using EnhancedWebAccessibility
.