title: Read tag NFC ID from foreground dispatch
body: <p>I am trying to read an NFC tag ID. I know I wont be able to read the data as it is a secure tag (MBTA Fare card). I would like to read the tags unique ID and toast that value. I have successfully gotten the NFC intent to work, so that when a tag is scanned my app attempts to handle it. However app does not show the toast with the tag id.</p>
  
  <pre><code>    package com.example.nfctest;
  
  import android.nfc.NdefMessage;
  import android.nfc.NfcAdapter;
  import android.nfc.Tag;
  import android.nfc.tech.NfcF;
  import android.os.Bundle;
  import android.app.Activity;
  import android.app.PendingIntent;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.content.IntentFilter.MalformedMimeTypeException;
  import android.util.Log;
  import android.view.Menu;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
       private NfcAdapter mAdapter;
          private PendingIntent mPendingIntent;
          private IntentFilter[] mFilters;
          private String[][] mTechLists;
          private int mCount = 0;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mAdapter = NfcAdapter.getDefaultAdapter(this);
  
          // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
          // will fill in the intent with the details of the discovered tag before delivering to
          // this activity.
          mPendingIntent = PendingIntent.getActivity(this, 0,
              new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
  
      // Setup an intent filter for all MIME based dispatches
  
  
  
      IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
      try {
          ndef.addDataType("*/*");
      } catch (MalformedMimeTypeException e) {
          throw new RuntimeException("fail", e);
      }
      mFilters = new IntentFilter[] {
  
      };
  
      // Setup a tech list for all NfcF tags
      mTechLists = new String[][] { new String[] { NfcF.class.getName() } };
  }
  public void onResume() {
      super.onResume();
      mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists);
  
  }
  
  @Override
  public void onNewIntent(Intent intent) {
      Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
      CharSequence text = ("Discovered tag " + ++mCount + " with intent: " + intent);
      int duration = Toast.LENGTH_SHORT;
  
      Tag myTag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
  
  
      Toast toast = Toast.makeText(MainActivity.this,myTag.getId().toString() , duration);
      toast.show();
  }
  
  
  @Override
  public void onPause() {
      super.onPause();
      //mAdapter.disableForegroundDispatch(this);
      throw new RuntimeException("onPause not implemented to fix build");
  }
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p>It no longer crashes, just doesn't do the toast with the ID.</p>