android - Implementing accessability on custom view gives no verbal feedback -


i have turned accessability on, , device speaks navigate around.

i have custom seekbar , have implemented 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, device not giving feedback. expect current score read back, nothing.

does have insight?

if you're extending progressbar, can set text outgoing type_view_selected events. these sent automatically user adjusts seek bar.

@override public void oninitializeaccessibilityevent(accessibilityevent event) {     super.oninitializeaccessibilityevent(event);     event.gettext().add(...); } 

however, looks may have extended view. in case, need use slight workaround , trigger announcement sending view_focused event on ics, or use announceforaccessibility api on jellybean , above. require support-v4 library , this:

/** parent context. used obtain string resources. */ private final context mcontext;  /**  * accessibility manager context. used check  * accessibility enabled state, send raw accessibility events.  */ private final accessibilitymanager ma11ymanager;  /**  * generates , dispatches sdk-specific spoken announcement.  * <p>  * backwards compatibility, we're constructing event scratch  * using appropriate event type. if application targets sdk  * 16+, can call view.announceforaccessibility(charsequence).  * </p>  *  * @param text text announce.  */ private void announceforaccessibilitycompat(charsequence text) {     if (!ma11ymanager.isenabled()) {         return;     }      // prior sdk 16, announcements made through focused     // events. jelly bean (sdk 16) added support speaking text verbatim     // using announcement event type.     final int eventtype;     if (build.version.sdk_int < 16) {         eventtype = accessibilityevent.type_view_focused;     } else {         eventtype = accessibilityeventcompat.type_announcement;     }      // construct accessibility event minimum recommended     // attributes. event without class name or package may dropped.     final accessibilityevent event = accessibilityevent.obtain(eventtype);     event.gettext().add(text);     event.setenabled(isenabled());     event.setclassname(getclass().getname());     event.setpackagename(mcontext.getpackagename());      // jellybean mr1 requires source view set window id.     final accessibilityrecordcompat record = new accessibilityrecordcompat(event);     record.setsource(this);      // sends event directly through accessibility manager. if     // application targets sdk 14+, should call     // getparent().requestsendaccessibilityevent(this, event);     ma11ymanager.sendaccessibilityevent(event); } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -