title: NotificationListenerService methods not getting called once it has crashed
body: <p>Just take this github repository as a reference.
  <a href="https://github.com/mukesh4u/NotificationListener" rel="nofollow noreferrer">https://github.com/mukesh4u/NotificationListener</a></p>
  
  <p>Since calling <code>getActiveNotifications()</code> function in the <code>onCreate()</code> method of the <code>NotificationService</code> class returns null, the statement</p>
  
  <pre><code>StatusBarNotification notifications[] = getActiveNotifications();
  </code></pre>
  
  <p>assigns with a null array for <code>notifications</code>.</p>
  
  <p>Because of that, inserting the following code in the <code>onCreate()</code> method of the <code>NotificationService</code> class</p>
  
  <pre><code>StatusBarNotification notifications[] = getActiveNotifications();
  for(StatusBarNotification item : notifications)
  {
      if(item != null)
      {
          Bundle extras = item.getNotification().extras;
          String title = extras.getString("android.title");
          Log.i("Title", title);
      }
  }
  </code></pre>
  
  <p>crashes the application with the message</p>
  
  <blockquote>
    <p>Attempt to get length of null array</p>
  </blockquote>
  
  <p>and stops the <code>NotificationListenerService</code> which had been running previously.</p>
  
  <p>Once if it has stopped, by launching the application again the overridden methods of <code>onCreate()</code>, <code>onNotificationPosted(StatusBarNotification sbn)</code> and <code>onNotificationRemoved(StatusBarNotification sbn)</code> in the <code>NotificationService</code> class do not get called again.</p>
  
  <p>Is there any way to make them work by launching the application again just by making some changes in the code or by making some changes to the settings or configuration of the application, without the need to uninstall and reinstall the application again or the need to block the application from listening to notifications and allowing it to listen to notifications again?</p>