這個包中的類用於無障礙服務的開發提供替代或增強的反饋給用戶、當Accweaaibiltyservice被啓動、AccessibiltyService會接受系統的回調並在後臺運行、這些事件指的是在用戶接口之間的的狀態轉換、比如、焦點變化、按鈕被點擊。這樣的服務擁有選擇請求查詢活動窗口的能力。開發一個需要輔助拓展的這個類、並抽象起方法、AccessibiltyServiceIno介紹了Accessibiltyservice。根據這個的封裝消息,系統爲AccessibiltyserviceEvent發出一個Accessibiltyservice的通知
開發者可以搭建自己的Accessibiltyservice的服務、這個可以加強可用性、例如聲音、物理反饋、和其他的操作模式
Accessibiltyservice可以爲應用程序或這一組應用程序提供增強功能
官方文檔中有三篇介紹 我這裏介紹下Accessibiltyservice的使用
新建一個類Accessibiltyservice、並在項目清單中註冊它
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.metck.accessibilityservicetest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.metck.accessibilityservicetest.ServiceEntity" >
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
</application>
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
<pre class="plain" name="code">
實現ServiceEntity類中的幾個重要的重載的方法、
onServiceConnec'ted() 系統會在成功 連接上服務的時候調用這個方法、在這個方法裏面可以做初始化的工作、例如設別聲音震動、也可以在調用getServiceIno進行配置
onAccessibilityEvent() 必須實現這個方法、通過這個方法可以接受系統發來的AccessibilityService、接下來是AccessibilityEveny是經過過濾的、過濾是在配置工作設置的
onInerrupt() 必須實現這個方法 這個系統在中斷Accessibilityservice返回響應時調用、整個生命週期會被調用多次