android 按钮中断,android – 如何“中断”在AccessibilityService中执行的操作?
我想做什么/我做了什么:我正在嘗試為視障用戶制作一個非常基本的TalkBack版本.我做了一個簡單的輔助功能服務,讀取用戶點擊的按鈕的contentDescription并大聲讀出.
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
// get the source node of the event
AccessibilityNodeInfo source = event.getSource();
if (source == null) {
return;
}
// Check if a button is clicked and speak out the content
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED
&& BUTTON_CLASS_NAME.equals(source.getClassName()) {
Log.d("Button clicked", source.getViewIdResourceName().toString());
convertTextToSpeech(source.getContentDescription().toString());
}
if (source != null)
source.recycle();
return;
}
問題:但是,這樣一來,用戶就無法在按下單擊按鈕之前實際執行觸發的操作之前聽取按鈕的描述.當用戶收聽描述時,已經點擊了按鈕并且已經執行了動作.
問題:如何中斷操作(例如:在單擊按鈕后打開新活動),以便用戶可以使用我提供的反饋安全地瀏覽屏幕上的當前視圖,而無需啟動新活動或觸發其他操作?
類似于Talkback中發生的事情:用戶單擊以聽取描述,雙擊以執行操作.除非用戶雙擊,否則Talkback如何阻止動作發生?我已經研究過TouchExplorationMode,但我猜它主要用于手勢而不是點擊.
總結
以上是生活随笔為你收集整理的android 按钮中断,android – 如何“中断”在AccessibilityService中执行的操作?的全部內容,希望文章能夠幫你解決所遇到的問題。