AccessibilityManager 使用笔记
目录
简介
System level service that serves as an event dispatch for AccessibilityEvents, and provides facilities for querying the accessibility state of the system. Accessibility events are generated when something notable happens in the user interface, for example an Activity starts, the focus or selection of a View changes etc. Parties interested in handling accessibility events implement and register an accessibility service which extends AccessibilityService.
该服务为系统级服务, 用于分发AccessibilityEvents事件并提供用于查询系统可访问行状态的工具。当用户界面中一些明显的事件发生可访问性事件发生时可访问性事件将被生成,例如一个Activity 开始,一个View的焦点或者选择状态发生变化等。对处理可访问性事件感兴趣的各方可以通过实现和继承AccessibilityService类后注册可访问性服务。
摘要
内部类
类名 | 描述 | 备注 |
---|---|---|
AccessibilityManager.AccessibilityStateChangeListener | 监听系统的可访问性状态 | |
AccessibilityManager.TouchExplorationStateChangeListener | 监听系统的触摸探测状态 |
常量
名称 | 描述 | 备注 |
---|---|---|
int FLAG_CONTENT_CONTROLS | 使用该标志去指示超时的Ui内容包含交互性控件 | |
int FLAG_CONTENT_ICONS | 使用此标志指示超时的UI内容包含图标。 | |
int FLAG_CONTENT_TEXT | 使用该标志去指示超时的UI内从包含文本 |
方法
名称 | 描述 | 备注 |
---|---|---|
void addAccessibilityRequestPreparer(AccessibilityRequestPreparer preparer) | 注册一个AccessibilityRequestPreparer监听者 | |
boolean addAccessibilityStateChangeListener(AccessibilityManager.AccessibilityStateChangeListener listener) | 注册一个AccessibilityStateChangeListener以更改系统的全局辅助性状态 | |
void addAccessibilityStateChangeListener(AccessibilityManager.AccessibilityStateChangeListener listener, Handler handler) | 注册一个AccessibilityStateChangeListener以更改系统的全局辅助性状态 | |
void addTouchExplorationStateChangeListener(AccessibilityManager.TouchExplorationStateChangeListener listener, Handler handler) | 注册一个TouchExplorationStateChangeListener以更改系统的全局触摸浏览状态 | |
boolean addTouchExplorationStateChangeListener(AccessibilityManager.TouchExplorationStateChangeListener listener) | 注册一个TouchExplorationStateChangeListener以更改系统的全局触摸浏览状态 | |
List |
此方法在API级别15中已弃用。使用getInstalledAccessibilityServiceList() | |
List |
返回给定反馈类型的已启用辅助功能的AccessibilityServiceInfos。 | |
List |
返回已安装了辅助性功能服务的AccessibilityServiceInfos | |
int getRecommendedTimeoutMillis(int originalTimeout, int uiContentFlags) | 获取建议的用户更改UI所需的超时时间 | |
void interrupt() | 对于所有的可访问性服务请求反馈中断 | |
static boolean isAccessibilityButtonSupported() | 检测系统导航区域内是否支持辅助性按钮 | |
boolean isEnabled() | 返回系统是否开启了辅助性服务 | |
boolean isTouchExplorationEnabled() | 返回系统是否开启了触摸探测 | |
void removeAccessibilityRequestPreparer(AccessibilityRequestPreparer preparer) | 注销AccessibilityRequestPreparer. | |
boolean removeAccessibilityStateChangeListener(AccessibilityManager.AccessibilityStateChangeListener listener) | 注销AccessibilityStateChangeListener. | |
boolean removeTouchExplorationStateChangeListener(AccessibilityManager.TouchExplorationStateChangeListener listener) | 注销TouchExplorationStateChangeListener. | |
void sendAccessibilityEvent(AccessibilityEvent event) | 发送一个 AccessibilityEvent |