package com.example.android.apis.accessibility;
import android.accessibilityservice.AccessibilityService;
import android.view.accessibility.AccessibilityEvent;
public class MyAccessibilityService extends AccessibilityService {
...
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
// 접근성 이벤트 처리 코드를 추가합니다.
}
@Override
public void onInterrupt() {
// 접근성 서비스가 중단되었을 때의 처리 코드를 추가합니다.
}
...
}
<service
android:name=".MyAccessibilityService"
android:label="@string/accessibility_service_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="true">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
<string name="accessibility_service_name">[접근성서비스이름]</string>
<string name="accessibility_service_description">[접근성서비스설명]</string>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFlags="flagDefault"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:description="@string/accessibility_service_description"
android:settingsActivity=".YourAccessibilityServiceSettingsActivity" />
YourAccessibilityServiceSettingsActivity 항목에는 AccessvilityService를 구현한 Activity를 넣으면 됩니다.