title: How to use NFC ACTIONS
body: <p>I am trying to register a receiver programmatically to get notified once an NFC tag is detected. As shown in my code I registered for the desired action and I created the broadcast receiver programmatically. I also added the required permission in the manifest file but the problem is that <code>onReceive</code> is never called.</p>
  
  <p>Please let me know what I am doing wrong and how to fix it.</p>
  
  <pre><code>IntentFilter intentFilter1 = new IntentFilter();
  intentFilter1.addAction("android.nfc.action.TAG_DISCOVERED");
  registerReceiver(mBCR_TAG_DISCOVERED, intentFilter1);
  
  private BroadcastReceiver mBCR_TAG_DISCOVERED = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          mTv.setText("mBCR_TAG_DISCOVERED");
      }
  };
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="example.com.myapplication"&gt;
  
  &lt;uses-permission android:name="android.permission.NFC" /&gt;
  
  &lt;uses-feature
      android:name="android.hardware.nfc"
      android:required="true" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>