title: NotificationListenerService Implementation
body: <p>I am trying to implement NotificationListnerService which is added in android 4.3 but I am not able to get the notification details. </p>
  
  <p>My code are as below</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
          mBuilder.setSmallIcon(R.drawable.ic_launcher);
          mBuilder.setContentTitle("notification test");
          mBuilder.setContentText("Notification text");
          mBuilder.setAutoCancel(true);
          Intent resultIntent = new Intent(this, ResultActivity.class);
          TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
          // Adds the back stack for the Intent (but not the Intent itself)
          stackBuilder.addParentStack(ResultActivity.class);
          // Adds the Intent that starts the Activity to the top of the stack
          stackBuilder.addNextIntent(resultIntent);
          PendingIntent resultPendingIntent =
                  stackBuilder.getPendingIntent(
                      0,
                      PendingIntent.FLAG_UPDATE_CURRENT
                  );
          mBuilder.setContentIntent(resultPendingIntent);
          NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
          manager.notify(1, mBuilder.build());
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  
  public class NotificationListenerTesting extends NotificationListenerService{
  
      public static String TAG = "NotificationListenerTesting";
      //private StatusBarNotification[] mStatusBarNotification;
  
      @Override
      public void onCreate(){
          super.onCreate();
          Log.d(TAG, "Inside on create");
      }
      @Override
      public IBinder onBind(Intent intent) {
          return null;
      }
      @Override
      public void onNotificationPosted(StatusBarNotification sbn) {
          TAG = "onNotificationPosted";
          Log.d(TAG, "id = " + sbn.getId() + "Package Name" + sbn.getPackageName() + 
                  "Post time = " + sbn.getPostTime() + "Tag = " + sbn.getTag());
      }
      @Override
      public void onNotificationRemoved(StatusBarNotification sbn) {
          TAG = "onNotificationRemoved";
          Log.d(TAG, "id = " + sbn.getId() + "Package Name" + sbn.getPackageName() + 
                  "Post time = " + sbn.getPostTime() + "Tag = " + sbn.getTag());
  
      }
  
  }
  </code></pre>
  
  <p>Android manifest file is </p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.notificationtest"
      android:versionCode="1"
      android:versionName="1.0" &gt;
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="18" /&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.notificationtest.MainActivity"
              android:label="@string/app_name" &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="com.example.notificationtest.ResultActivity"&gt;&lt;/activity&gt;
          &lt;service android:name="com.example.notificationtest.NotificationListenerTesting"
              android:label="notification"
              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;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>but after notification click or on notification post NotificationListenerService is not getting called , Whats wrong in this or did I miss somthing ? How to implement it ?</p>