Jitendar M
Jitendar M

Reputation: 643

ApiDemo's: Android Accessibility Node Provider is this working with talkback?

I was exploring the API Demos provided in android sdk, android version > 4.1 . API Demos -> Accessibility -> Accessibility Node Provider

The AccessibilityNodeProvider contains some custom views with Red, Green, Blue colors. As mentioned in the activity , i enabled the talkback and i tried to hover on the views. Talkback couldn't read the colors. Talkback is reading the text available in the activity but not the colors. I was wondering does Talkback reads the colors (custom views) in the activity ?

Thanks in advance

Upvotes: 0

Views: 1640

Answers (2)

spear
spear

Reputation: 21

In the package com.example.android.apis.accessibility in the AccessibilityNodeProviderActivity class, find the sendAccessibilityEventForVirtualView() method. You need to set the eventType on the AccessibilityEvent to AccessibilityEvent.TYPE_ANNOUNCEMENT like so:

event.getText().add(virtualView.mText);
event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event);

That should make it announce the text. But it still doesn't highlight the view -- don't know if the expected behaviour is that the node should be highlighted.

Upvotes: 2

jbm
jbm

Reputation: 1492

I've found this Google Code example to be a better example of speaking text in a node provider setup.

(Old answer below.)

In the AccessibilityNodeProviderActivity class, look at the method sendAccessibilityEventForVirtualView(). You’ll see that the text set into the event is the text defined in accessibility_node_provider.xml. You would replace that text with a wording of the different color values to get what you asked for.

Upvotes: 0

Related Questions