Reputation: 23
So, I have an Android application written in Java. I want to be able to use talkback in the accessibility option for those that are visually impaired. As the user swipes through the activity, the talkback "focuses" on various components and I want to be able to know this:
1) How to know if it's "focused" on a certain component (ex, textview)?
2) When it's "focused" on that certain component, how to interrupt it to play my own audio file then go back and let talkback take over again?
Thank you in advance!
---- edit
Just to be a little bit more clear, in case you're not familiar with talkback...
Once the user enables talkback, it reads out everything on the phone screen. If the user wants to select an application, the user will keep swiping right,left,up, or down until that application name is highlighted/focused and announced by the talkback. So, I want to know when a specific textview is highlighted.
Upvotes: 2
Views: 2772
Reputation: 18860
Answer A:
Find the views View.AccessibilityDelegate.
Then override the following method:
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if(event.getEventType() == TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
/*do your stuff here*/
} else {
return super.onRequestSendAccessibilityEvent(child, event);
}
}
You want to look for events of the type TYPE_VIEW_ACCESSIBILITY_FOCUSED
.
Answer B: Under WCag 2.0 Guideline 3.2, it is generally considered poor accessibility to have things automatically happen on focus. Instead of figuring out how to make the accessibility framework do something that is generally considered inaccessible, just don't do it instead :).
Upvotes: 1