I have turned accessability on, and my device speaks as I navigate around.
I have a custom seekbar
and have implemented the folllowing:
onTouchEvent
excerpt:
...
case MotionEvent.ACTION_MOVE:
getParent().requestDisallowInterceptTouchEvent(true);
setTouchAngle(pointToAngle(touchX, touchY));
score = getScoreFromAngle(angleStart,touchAngle);
if (onScoreSetListener != null) {
onScoreSetListener.onScorePoll(this, score);
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
}
break;
...
onPopulateAccessibilityEvent
method:
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
LogUtils.i(TAG,"onPopulateAccessibilityEvent()",null);
switch (event.getEventType()) {
case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
LogUtils.d(TAG,"dispatchPopulateAccessibilityEvent() TYPE_VIEW_TEXT_CHANGED",null);
event.getText().add(String.valueOf(getScore()));
break;
}
}
I can see onPopulateAccessibilityEvent
being called in LogCat
successfully, but the device is not giving any feedback. I expect the current score to be read back, but nothing.
Does anyone have any insight?
If you're extending
ProgressBar
, you can set the text for outgoingTYPE_VIEW_SELECTED
events. These are sent automatically as the user adjusts the seek bar.However, it looks like you may have extended
View
. In this case, you will need to use a slight workaround and trigger an announcement by sending aVIEW_FOCUSED
event on ICS, or use theannounceForAccessibility
API on JellyBean and above. Which would require the support-v4 library and would look like this: