title: Can't cancel Notification using NotificationListenerService
body: <p>This is my service: </p>
  
  <pre><code>public class Listener extends NotificationListenerService {
      Context context;
  
      @Override
  
      public void onCreate() {
          super.onCreate();
          context = getApplicationContext();
      }
  
      @Override
  
      public void onNotificationPosted(StatusBarNotification sbn) {
          String pack = sbn.getPackageName();
          String ticker = sbn.getNotification().tickerText.toString();
          Bundle extras = sbn.getNotification().extras;
          String title = extras.getString("android.title");
          String text = extras.getCharSequence("android.text").toString();
  
          Log.i("Msg",pack);
          Log.i("Msg",ticker);
          Log.i("Msg",title);
          Log.i("Msg",text);
  
          Intent msgrcv = new Intent("Msg");
          msgrcv.putExtra("package", pack);
          msgrcv.putExtra("ticker", ticker);
          msgrcv.putExtra("title", title);
          msgrcv.putExtra("text", text);
              LocalBroadcastManager.getInstance(context).sendBroadcast(msgrcv);
          Toast.makeText(context, "GOT SOMETHING", Toast.LENGTH_LONG).show();
  
   //final String T=  sbn.getKey();
  
          Listener.this.cancelAllNotifications();
      }
  
      @Override
  
      public void onNotificationRemoved(StatusBarNotification sbn) {
          Log.i("Msg","Notification Removed");
      }
  }
  </code></pre>
  
  <p>For testing, I would like to <strong>DISMISS ALL NOTIFICATIONS FROM ANY APP</strong> as soon as they arrive. I have called  <code>Listener.this.cancelAllNotifications();</code> inside onNotificationPosted, but it does not work. </p>
  
  <p>What am I doing wrong ? I am testing this on android version 5.0.2.</p>
  
  <p>P.S. </p>
  
  <p>I HAVE added the permissions along with the intent filter, as android mentions.</p>
  
  <pre><code>&lt;service android:name=".NotificationListener"
            android:label="@string/service_name"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"&gt;
       &lt;intent-filter&gt;
           &lt;action android:name="android.service.notification.NotificationListenerService" /&gt;
       &lt;/intent-filter&gt;
   &lt;/service&gt;
  </code></pre>