Is it possible in any way to set an Accessibility Delegate on a Menu Item? My app uses text-to-speech and I want to execute some custom code before TalkBack starts speaking the content description of my menu item (which happens when the menu item gets accessibility focus). Otherwise, the text-to-speech from my app will clash with TalkBack's text-to-speech.
Update: My app fetches a sentence from a WebView, highlights it and reads it using the TTS engine. When the sentence has been spoken, the onDone() callback starts the same method but for the next sentence.
Since TalkBack and my app are using the same TTS engine, only one utterance is allowed to be spoken at a time. So my app is reading its WebView sentence per sentence, but then the user focuses on a Menu Item and TalkBack will read its description. Because my speech utterance was interrupted, onDone() will be called (onDone() cannot distinguish whether the utterance was fully spoken or simply interrupted), so the speakNextSentence() will be called, even though my previous sentence might be interrupted after only two words. I'd like to somehow put the isPaused boolean to true before the accessibility event of the Menu Item is fired.
private class ttsUtteranceListener extends UtteranceProgressListener {
@Override
public void onStart(String utteranceId) {
}
@Override
public void onDone(final String utteranceId) {
if (!isPaused) {
...
speakNextSentence();
...
}
}
@Override
public void onError(String utteranceId) {
}