title: App not working on old Android version with NFC plugin
body: <p>I've been coding an app for Android with Cordova to read non NDEF NFC Cards.
  The tag ID is then sent to a server and registered into a database, but that's not the point.</p>
  
  <p>I made the app and tested it on my Nexus 4 on Android 5.1.1 and I wanted to try on an old android version.</p>
  
  <p>So I took a coworker's phone that's in 4.0.2 and the app is not working on it.</p>
  
  <p>I tried adding this to my <code>config.xml</code>:</p>
  
  <pre><code>&lt;preference name="android-minSdkVersion" value="14" /&gt;
  &lt;preference name="android-targetSdkVersion" value="21" /&gt;
  </code></pre>
  
  <p>But it doesn't make any difference, the app just get stuck. So with a bit of troubleshooting I think the app doesn't even make it to the <code>deviceready</code> call.</p>
  
  <p>I don't know if I'm the only one having this problem, but I'd love some help.
  Here's the code:</p>
  
  <pre><code>var app = {
      initialize: function () {
          this.bind();
      },
      bind: function () {
          document.addEventListener('deviceready', this.deviceready, false);
          document.addEventListener('online', uploadScans, false);
      },
      deviceready: function () {
          navigator.geolocation.getCurrentPosition(app.getPosition);
          tagContents = document.getElementById('tagContents');
  
          if (!window.localStorage.getItem("id")) {
              window.localStorage.setItem("id", Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1));
          }
          document.getElementById('id').innerHTML = "Code unique: " + window.localStorage.getItem("id");
  
          nfc.addNdefListener(
              app.onNdef
          );
  
          if (device.platform == "Android") {
  
              // Android reads non-NDEF tag. BlackBerry and Windows don't.
              nfc.addTagDiscoveredListener(
                  app.onNfc
              );
  
              // Android launches the app when tags with mime type text/pg are scanned
              // because of an intent in AndroidManifest.xml.
              // phonegap-nfc fires an ndef-mime event (as opposed to an ndef event)
              // the code reuses the same onNfc handler
              nfc.addMimeTypeListener(
                  'text/pg',
                  app.onNdef
              );
          }
  
          if (app.isOnline()) {
              app.uploadScans();
          }
      },
      onNfc: function (nfcEvent) {
  
          var tag = nfcEvent.tag;
  
          app.clearScreen();
  
          app.saveScan(tag);
          navigator.notification.vibrate(100);
      },
      onNdef: function (nfcEvent) {
  
          app.clearScreen();
  
          var tag = nfcEvent.tag;
  
          // BB7 has different names, copy to Android names
          if (tag.serialNumber) {
              tag.id = tag.serialNumber;
              tag.isWritable = !tag.isLocked;
              tag.canMakeReadOnly = tag.isLockable;
          }
  
  
          app.saveScan(tag);
  
          navigator.notification.vibrate(100);
      },
      clearScreen: function () {
  
          tagContents.innerHTML = "";
  
      },
      saveScan: function (tag) {
          var d = new Date();
  
          var scan = {
              "deviceSN": window.localStorage.getItem("id"),
              "reference": nfc.bytesToHexString(tag.id),
              "scanTime": d.toJSON(),
              "latitude": app.pos.latitude,
              "longitude": app.pos.longitude
          };
  
          var scans = window.localStorage.getItem("scans");
          if (scans != null) {
              scans = JSON.parse(scans);
              scans.scans.push({scan});
              scans.scans.totalcount++;
          } else {
              var scans = {
                  "scans": [
                      {
                          scan
                      }
                  ],
                  "totalcount": 1
              };
          }
          tagContents.innerHTML = "Scan added at " + d.toString();
          window.localStorage.setItem("scans", JSON.stringify(scans));
          if (app.isOnline()) {
              app.uploadScans();
          }
      },
      getPosition: function (position) {
          app.pos = {"latitude": position.coords.latitude, "longitude": position.coords.longitude};
      },
      uploadScans: function () {
          tagContents.innerHTML += "\n Uploading...";
  
          var http = new XMLHttpRequest();
  
          var post_data = window.localStorage.getItem("scans");
  
          var url = 'http://example.com/scan.php';
  
          http.open("POST", url, true);
  
          http.setRequestHeader("Content-type", "application/json");
          http.setRequestHeader("Content-lenght", post_data.length);
  
          // post the data
          http.send(post_data);
  
          deleteScans();
      },
      isOnline: function () {
          var state = navigator.connection.type;
  
          switch (state) {
              case "unknown":
                  return false;
              case "ethernet":
                  return true;
              case "wifi":
                  return true;
              case "2d":
                  return true;
              case "3g":
                  return true;
              case "4g":
                  return true;
              case "cell":
                  return true;
              case "none":
                  return false;
          }
      }
  };
  
  function deleteScans() {
      window.localStorage.removeItem("scans");
  }
  </code></pre>
  
  <p>Thank you in advance!</p>