title: How to configure Android AccessibilityService
body: <p>I am investigating Android <code>AccessibilityService</code> and wanted to see all possible types of events,
  gestures and Key Events.</p>
  
  <p>I am able to receive all <code>public void onAccessibilityEvent(final AccessibilityEvent accessibilityEvent) {}</code></p>
  
  <p>however my service nevers receives <code>protected boolean onGesture(int gestureId) {}</code> or 
  <code>protected boolean onKeyEvent(KeyEvent event) {}</code> calls.</p>
  
  <p>When I enable my accessibility service in the accessibility settings I see the service connect OK</p>
  
  <p>and I can see the service logging out from the <code>public void onAccessibilityEvent(final AccessibilityEvent accessibilityEvent) {}</code> method</p>
  
  <p>What have I not configured? or configured incorrectly?</p>
  
  <p>My Manifest file looks like this</p>
  
  <pre><code>&lt;service
      android:name=".MyAccessibilityService"
      android:label="My Accessibility"
      android:enabled="true"
      android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.accessibilityservice.AccessibilityService" /&gt;
      &lt;/intent-filter&gt;
      &lt;meta-data
          android:name="android.accessibilityservice"
          android:resource="@xml/accessibilityservice" /&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>The xml accessibilityservice contents are :-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
      android:accessibilityEventTypes="typeAllMask"
      android:accessibilityFeedbackType="feedbackSpoken"
      android:accessibilityFlags="flagDefault"
      android:canRequestEnhancedWebAccessibility="true"
      android:canRequestFilterKeyEvents="true"
      android:canRequestTouchExplorationMode="true"
      android:canRetrieveWindowContent="true"
      android:notificationTimeout="1000"
      android:packageNames="com.research.my.accessibility" /&gt;
  </code></pre>
  
  <p>The service AccessibilityServiceInfo is as follows:-</p>
  
  <pre><code>@Override
  protected void onServiceConnected() {
      super.onServiceConnected();
      Log.d("TAG", "onServiceConnected");
  
      final AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo();
      accessibilityServiceInfo.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
      accessibilityServiceInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK;
      accessibilityServiceInfo.packageNames = new String[] {"com.research.my.accessibility"};
      accessibilityServiceInfo.notificationTimeout = 1000;
      setServiceInfo(accessibilityServiceInfo);
  }
  </code></pre>