title: Android accessibility service detect notification
body: <p>I'm trying to make my app detect whenever a notification is displayed. I've enabled it in the settings app and <code>onServiceConnected</code> does get called, however when I create a notification or receive an e-mail through the gmail app nothing happens, <code>onAccessibilityEvent</code> does not get called.</p>
  
  <p>Android manifest:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.test.slide"
  android:versionCode="1"
  android:versionName="1.0"&gt;
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="15"/&gt;
  &lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/&gt;
  &lt;uses-permission android:name="android.permission.GET_TASKS"/&gt;
  &lt;application android:label="Slide"
      android:icon="@drawable/ic_launcher"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".Settings"
          android:label="Slide"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN"/&gt;
              &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".Tools"
          android:label="Slide"
          android:theme="@android:style/Theme.Translucent.NoTitleBar"&gt;
      &lt;/activity&gt;
      &lt;service android:name=".LocalService"/&gt;
      &lt;service android:name=".NotificationService"
          android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
          android:label="Slide"
          android:enabled="true"
          android:exported="false"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.accessibilityservice.AccessibilityService"/&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>NotificationService.java</p>
  
  <pre><code>package com.test.slide;
  
  import android.accessibilityservice.AccessibilityService;
  import android.accessibilityservice.AccessibilityServiceInfo;
  import android.view.accessibility.AccessibilityEvent;
  
  public class NotificationService extends AccessibilityService {
  @Override
  public void onAccessibilityEvent(AccessibilityEvent event) {
      System.out.println("onAccessibilityEvent");
      if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
          System.out.println("notification: " + event.getText());
      }
  }
  @Override
  protected void onServiceConnected() {
      System.out.println("onServiceConnected");
      AccessibilityServiceInfo info = new AccessibilityServiceInfo();
      info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
      info.notificationTimeout = 100;
      info.feedbackType = AccessibilityEvent.TYPES_ALL_MASK;
      setServiceInfo(info);
  }
  
  @Override
  public void onInterrupt() {
      System.out.println("onInterrupt");
  }
  }
  </code></pre>
  
  <p>Thanks for any help.</p>