0

The following code does exactly what I need it to do:

NdefRecord[] ndefRecords = new NdefRecord[0];
ndefRecords[0] = NdefRecord.createTextRecord ("en", "1");
ndefRecords[1] = NdefRecord.createApplicationRecord("com.example.myapp");
NdefMessage ndefMessage = new NdefMessage(ndefRecords);
writeNdefMessage(tag, ndefMessage);

However....the "createTextRecord" (ln 2) command is only supported at API levels of 21 and above. Does anyone know what the predecessor to this command was...that would operate at API level 15 and above? I'm only trying to write a "Text" record to a variable to be used in a function, but I can't seem to find the appropriate command? Thanks so much for any help!!

Leo
  • 21
  • 3
  • Btw. Text records are intended for storing *human-readable* text. For your scenario (storing some data string that is automatically processed by an app), an NFC Forum external record or a MIME type record would be the better choice. – Michael Roland Sep 14 '16 at 14:41
  • 1
    Ahh, okay, I didn't realize that! Thanks for pointing me in the right direction...I'll read up on those topics! Thanks Michael. – Leo Sep 14 '16 at 17:23
  • You can view the source for the method here if you want to pull it out and use it: http://grepcode.com/file/repo1.maven.org/maven2/org.robolectric/android-all/5.0.0_r2-robolectric-1/android/nfc/NdefRecord.java#NdefRecord.createTextRecord%28java.lang.String%2Cjava.lang.String%29 – griffinjm Sep 15 '16 at 14:43
  • Thanks jgriffin, I'm going to have a look at this over the weekend. This looks to be exactly what I'm needing! – Leo Sep 16 '16 at 18:15

0 Answers0