title: NFC tag has UID/serial number but getByteArrayExtra returns null
body: <p>I am working on an app that is in its final stages when I was asked to make changes to it to read the unique serial number of NFC tags. No big problem there, however in the case of some of the tags the serial number is returned as null.</p>
  
  <p>When using the NFC Tools app to inspect the tag the serial number is there but <code>intent.getByteArrayExtra()</code> method called with <code>NfcAdapter.EXTRA_ID</code> as parameter returns <code>null</code> in the case of those tags.</p>
  
  <p>Below you have my Android manifest and the code I used to get the UID if it helps. </p>
  
  <pre><code>@Override
  protected String doInBackground(Tag... params) {
      Tag tag = params[0];
  
      // New code to deal with multiple tag versions (supports NfcA, NDEF, MifareUltralight)
  
      // parse tech list
      byte[] uid = getIntent().getByteArrayExtra(NfcAdapter.EXTRA_ID);
  
      String serialNumber = uidByteToHexString(uid);
  
      if (serialNumber != null &amp;&amp; !serialNumber.isEmpty()) {
          return serialNumber;
      }
  </code></pre>
  
  <p>Android Manifest</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="myPackageName here" &gt;
  
      &lt;!-- Application permissions go here, mainly NFC --&gt;
      &lt;uses-permission android:name="android.permission.NFC" /&gt;
      &lt;users-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:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MyActivityNameHere"
              android:configChanges="orientation|keyboardHidden|screenSize"
              android:label="@string/app_name"
              android:theme="@style/FullscreenTheme" &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;!-- NFC Intent Filters --&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.nfc.action.TECH_DISCOVERED" /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&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;intent-filter&gt;
                  &lt;action android:name="android.nfc.action.TAG_DISCOVERED" /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;/intent-filter&gt;
  
              &lt;meta-data android:name="android.nfc.action.TECH_DISCOVERED"
                  android:resource="@xml/nfc_tech_filter" /&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>My other question is: When reading tags some tags trigger the chooser dialog making me choose which application do I want to use to process the tag. Would it be possible to eliminate that and have just my app deal with NFC events while it is active?</p>
  
  <p>The tags I am using are NfcA, MifareUltralight and Ndef. If it helps.</p>