title: Foreground Dispatch system Issue in Android NFC
body: <p>I would like to make one particular NFC application among few other NFC application which should have the following capabilities<br>
  1. The application should be launched only when an NFC tag with a particular text(NDEF type) be scanned on the device. (It means my application should not be displayed if any other tags with text type is tapped )  </p>
  
  <ol>
  <li>While launching the application  the option for "Complete action using " and listing of all the NFC applications in the device should not be there  </li>
  </ol>
  
  <p>Here, I have implemented the foreground dispatch system, but it is only listing all the NFC applications with NDEF_DISCOVERED priority.   </p>
  
  <p>The code snippet for manifest file is as follows :</p>
  
  <pre><code>   &lt;activity android:name=".NFCDiscovered" android:label="@string/app_name"&gt;
         &lt;intent-filter&gt;
              &lt;action android:name="android.nfc.action.NDEF_DISCOVERED" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;data android:mimeType="text/plain" /&gt;
          &lt;/intent-filter&gt;  
      &lt;/activity&gt;
  
  
  &lt;/application&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.NFC" /&gt;
  &lt;uses-feature android:name="android.hardware.nfc" android:required="true" /&gt;
  </code></pre>
  
  <p>Here NFCDiscovered.java takes care of reading a particular text type NFC tag with foreground dispatch system. The code snippet for this as :  </p>
  
  <pre><code>    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.nfcreader);
      mAdapter = NfcAdapter.getDefaultAdapter(this);
  
      mPendingIntent = PendingIntent.getActivity(this, 0,new 
      Intent(this,getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);        
      IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
      try {
          ndef.addDataType("text/plain");
  
      } catch (MalformedMimeTypeException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } 
  
      mFilters = new IntentFilter[] { ndef }; 
  
      //resolveIntent(getIntent());
  
  }
  
  public void onResume() {
      super.onResume();
      // TODO Auto-generated method stub
      TextView myText= (TextView)findViewById(R.id.nfcTxt);
      super.onResume();        
      if (mAdapter != null) 
          mAdapter.enableForegroundDispatch(this, mPendingIntent, 
            mFilters,null);
  
  
  
  
  }
  protected void onNewIntent(Intent intent) { 
      NdefMessage[] msgs = null;
      if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())){
          Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
          if (rawMsgs != null) {
              msgs = new NdefMessage[rawMsgs.length];
              for (int i = 0; i &lt; rawMsgs.length; i++) {
                  msgs[i] = (NdefMessage) rawMsgs[i];
              }
          }
  
      }
      List&lt;TextRecord&gt; records = NdefMessageParser.parse(msgs[0]);
      String text = null;
      for(TextRecord local:records)
      {
           text = local.getText();
      }
      //myText.setText("text :"+msgs);
  
  
  
  }
  public void onPause() {        
      super.onPause();        
      if (mAdapter != null) mAdapter.disableForegroundDispatch(this);    
  }
  </code></pre>
  
  <p>It would be great if anyone can tell me what i'm missing.<br>
  Thanks in advance</p>