title: Not able to read notifications from other apps
body: <p>I want to read notifications from other apps in android , but I am not able to do so. These are my implementations to achieve same.
  This is my MainActivity.java</p>
  
  <pre><code>package com.example.demoapp;
  
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.localbroadcastmanager.content.LocalBroadcastManager;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.text.Html;
  import android.widget.TableLayout;
  import android.widget.TableRow;
  import android.widget.TextView;
  
  public class MainActivity extends AppCompatActivity {
      TableLayout tab;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          tab = (TableLayout)findViewById(R.id.tab);
           LocalBroadcastManager.getInstance(this).registerReceiver(onNotice, new IntentFilter("Msg"));
      }
      private BroadcastReceiver onNotice= new BroadcastReceiver() {
  
          @Override
          public void onReceive(Context context, Intent intent) {
              String pack = intent.getStringExtra("package");
              String title = intent.getStringExtra("title");
              String text = intent.getStringExtra("text");
              TableRow tr = new TableRow(getApplicationContext());
              tr.setLayoutParams(new TableRow.LayoutParams( TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
              TextView textview = new TextView(getApplicationContext());
              textview.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT,1.0f));
              textview.setTextSize(20);
              textview.setTextColor(Color.parseColor("#0B0719"));
              textview.setText(Html.fromHtml(pack +"&lt;br&gt;&lt;b&gt;" + title + " : &lt;/b&gt;" + text));
              tr.addView(textview);
              tab.addView(tr);
  
  
  
  
          }
      };
  }
  </code></pre>
  
  <p>This is my NotificationService class</p>
  
  <pre><code>package com.example.demoapp;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.service.notification.NotificationListenerService;
  import android.service.notification.StatusBarNotification;
  import android.util.Log;
  
  import androidx.localbroadcastmanager.content.LocalBroadcastManager;
  
  public class NotificationService 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("Package",pack);
          Log.i("Ticker",ticker);
          Log.i("Title",title);
          Log.i("Text",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);
  
  
      }
  
      @Override
  
      public void onNotificationRemoved(StatusBarNotification sbn) {
          Log.i("Msg","Notification Removed");
  
      }
  
  }
  </code></pre>
  
  <p>This is my AndroidManifest.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:dist="http://schemas.android.com/apk/distribution"
      package="com.example.demoapp"&gt;
  
      &lt;dist:module dist:instant="true" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&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;service android:name="com.example.demoapp.NotificationService"
              android:label="@string/app_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;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>This is my activity.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;TableLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/tab" /&gt;
      &lt;/ScrollView&gt;
      &lt;/LinearLayout&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p>I have tested app in Android 5 and above, it is not getting any notification details.  I gave permission to the app for reading permissions in android while testing on Android 6 and above versions.
  Suggest me where I am getting wrong.</p>